summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-06-25 13:29:52 +0000
committerBenny Prijono <bennylp@teluu.com>2009-06-25 13:29:52 +0000
commit3c973d3f99b2b4e458b8b95dc9aff90e934d06e5 (patch)
treeeca20dda37920d97d0a651cb8e9ffd23e58758f4
parent1028a42bfdd13453b39c3a19ebc59959df565bec (diff)
Ticket #773 (misc fixes): backported changes from #838:
- from r2749: protect pj_strdup() for case when source and destination string are the same pointer. Without this, destination string will contain garbage value. git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.0@2819 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib/include/pj/string_i.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/pjlib/include/pj/string_i.h b/pjlib/include/pj/string_i.h
index 1dcce8d6..f7e72eb9 100644
--- a/pjlib/include/pj/string_i.h
+++ b/pjlib/include/pj/string_i.h
@@ -32,6 +32,10 @@ PJ_IDEF(pj_str_t*) pj_strdup(pj_pool_t *pool,
pj_str_t *dst,
const pj_str_t *src)
{
+ /* Without this, destination will be corrupted */
+ if (dst == src)
+ return dst;
+
if (src->slen) {
dst->ptr = (char*)pj_pool_alloc(pool, src->slen);
pj_memcpy(dst->ptr, src->ptr, src->slen);