diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-06-04 22:08:16 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-06-04 22:08:16 +0000 |
commit | 7aa5e9c1f82139cb7065c95c7c2595bc511589c6 (patch) | |
tree | 7d30d05af94fe4a7515aea2719154b53b4c7ce83 /pjlib/include | |
parent | 677553788814cc29601fc1658827ba9a0c98fbe1 (diff) |
Misc (ticket #838):
- 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/trunk@2749 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/include')
-rw-r--r-- | pjlib/include/pj/string_i.h | 4 |
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); |