diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2016-10-24 03:22:46 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2016-10-24 03:22:46 +0000 |
commit | 00aa5887abe1fcef80ed2528aaad9f265c599267 (patch) | |
tree | ae1a92efe11f84ebb8a68cd0cded995c7279880b /pjsip | |
parent | 49d98191016269301f21542cc24ecf9d1a3c38f4 (diff) |
Misc (re #1945): Avoid calling memchr() or memcpy() with NULL pointer (thanks Kal from the patch).
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5468 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsip/print_util.h | 6 | ||||
-rw-r--r-- | pjsip/src/pjsip/sip_msg.c | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/pjsip/include/pjsip/print_util.h b/pjsip/include/pjsip/print_util.h index f8f9eb01..bd5d6f6b 100644 --- a/pjsip/include/pjsip/print_util.h +++ b/pjsip/include/pjsip/print_util.h @@ -29,8 +29,10 @@ #define copy_advance_check(buf,str) \ do { \ if ((str).slen >= (endbuf-buf)) return -1; \ - pj_memcpy(buf, (str).ptr, (str).slen); \ - buf += (str).slen; \ + if ((str).slen) { \ + pj_memcpy(buf, (str).ptr, (str).slen); \ + buf += (str).slen; \ + } \ } while (0) #define copy_advance_pair_check(buf,str1,len1,str2) \ diff --git a/pjsip/src/pjsip/sip_msg.c b/pjsip/src/pjsip/sip_msg.c index b5d2eb5f..a13f80e1 100644 --- a/pjsip/src/pjsip/sip_msg.c +++ b/pjsip/src/pjsip/sip_msg.c @@ -2013,7 +2013,7 @@ static int pjsip_via_hdr_print( pjsip_via_hdr *hdr, *buf++ = ' '; /* Check if host contains IPv6 */ - if (pj_memchr(hdr->sent_by.host.ptr, ':', hdr->sent_by.host.slen)) { + if (pj_strchr(&hdr->sent_by.host, ':')) { copy_advance_pair_quote_cond(buf, "", 0, hdr->sent_by.host, '[', ']'); } else { copy_advance_check(buf, hdr->sent_by.host); |