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: https://svn.pjsip.org/repos/pjproject/trunk@2749 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2009-06-04 22:08:16 +00:00
parent 57cab34be8
commit 7764f17927
1 changed files with 4 additions and 0 deletions

View File

@ -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);