Module: sip-router Branch: master Commit: 4b6cfe30388bd3cd95da2c8f540eedf991a4ee9c URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4b6cfe30...
Author: Marius Zbihlei marius.zbihlei@1and1.ro Committer: Marius Zbihlei marius.zbihlei@1and1.ro Date: Tue Jan 18 10:45:42 2011 +0200
modules_k/textops If s0.s is NULL do not memcpy it.
---
modules_k/textops/textops.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/modules_k/textops/textops.c b/modules_k/textops/textops.c index 5b0e3b5..f5da969 100644 --- a/modules_k/textops/textops.c +++ b/modules_k/textops/textops.c @@ -1475,13 +1475,15 @@ int add_hf_helper(struct sip_msg* msg, str *str1, str *str2, len=s0.len; if (str2) len+= str2->len + REQ_LINE(msg).uri.len;
- s = (char*)pkg_malloc(len); - if (!s) { - LM_ERR("no pkg memory left\n"); - return -1; + if (likely(len>0)){ + s = (char*)pkg_malloc(len); + if (!s) { + LM_ERR("no pkg memory left\n"); + return -1; + } + memcpy(s, s0.s, s0.len); }
- memcpy(s, s0.s, s0.len); if (str2) { memcpy(s+str1->len, REQ_LINE(msg).uri.s, REQ_LINE(msg).uri.len); memcpy(s+str1->len+REQ_LINE(msg).uri.len, str2->s, str2->len );