diff --git a/core/plug-in/sipctrl/SipCtrlInterface.cpp b/core/plug-in/sipctrl/SipCtrlInterface.cpp index 238219ba..41fb467f 100644 --- a/core/plug-in/sipctrl/SipCtrlInterface.cpp +++ b/core/plug-in/sipctrl/SipCtrlInterface.cpp @@ -295,11 +295,14 @@ int SipCtrlInterface::send(const AmSipReply &rep) hdrs_len += content_type_len(stl2cstr(rep.content_type)); } - char* hdrs_buf = new char[hdrs_len]; - char* c = hdrs_buf; - - copy_hdrs_wr(&c,msg.hdrs); - content_type_wr(&c,stl2cstr(rep.content_type)); + char* hdrs_buf = NULL; + if (hdrs_len) { + hdrs_buf = new char[hdrs_len]; + char* c = hdrs_buf; + + copy_hdrs_wr(&c,msg.hdrs); + content_type_wr(&c,stl2cstr(rep.content_type)); + } int ret = tl->send_reply(get_trans_bucket(h),(sip_trans*)t, rep.code,stl2cstr(rep.reason), diff --git a/core/plug-in/sipctrl/trans_layer.cpp b/core/plug-in/sipctrl/trans_layer.cpp index 26bab165..a3147bd3 100644 --- a/core/plug-in/sipctrl/trans_layer.cpp +++ b/core/plug-in/sipctrl/trans_layer.cpp @@ -192,8 +192,10 @@ int trans_layer::send_reply(trans_bucket* bucket, sip_trans* t, //contact_wr(&c,contact); //} - memcpy(c,hdrs.s,hdrs.len); - c += hdrs.len; + if (hdrs.len) { + memcpy(c,hdrs.s,hdrs.len); + c += hdrs.len; + } content_length_wr(&c,(char*)c_len.c_str());