summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);