From c6d5dec6f17197cad5b665fe630959ecaa8428a8 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Fri, 8 Feb 2008 17:50:31 +0000 Subject: [PATCH] fixed crash if extra headers were empty git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@705 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/plug-in/sipctrl/SipCtrlInterface.cpp | 13 ++++++++----- core/plug-in/sipctrl/trans_layer.cpp | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) 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());