Module: kamailio Branch: master Commit: 4015c6c47d6e4189788331757663fcd7ff988db2 URL: https://github.com/kamailio/kamailio/commit/4015c6c47d6e4189788331757663fcd7ff988db2
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2026-02-08T15:45:40+01:00 core: free dst earlier inside shm_str_dup_mode() --- Modified: src/core/ut.h --- Diff: https://github.com/kamailio/kamailio/commit/4015c6c47d6e4189788331757663fcd7ff988db2.diff Patch: https://github.com/kamailio/kamailio/commit/4015c6c47d6e4189788331757663fcd7ff988db2.patch --- diff --git a/src/core/ut.h b/src/core/ut.h index eac812cb749..16bbde5d239 100644 --- a/src/core/ut.h +++ b/src/core/ut.h @@ -882,6 +882,10 @@ static inline int shm_str_dup_mode(str *dst, const str *src, int mode) return -1; } + if(mode == 1 && dst->s != NULL) { + shm_free(dst->s); + } + /** * fallback actions: * - dst->len=0 @@ -898,9 +902,6 @@ static inline int shm_str_dup_mode(str *dst, const str *src, int mode) dst->len = src->len; } - if(mode == 1 && dst->s != NULL) { - shm_free(dst->s); - } dst->s = (char *)shm_malloc(dst->len + 1); if(dst->s == NULL) { SHM_MEM_ERROR; @@ -910,6 +911,7 @@ static inline int shm_str_dup_mode(str *dst, const str *src, int mode) /* avoid memcpy from NULL source - undefined behaviour */ if(src->s == NULL) { LM_WARN("shm_str_dup fallback; skip memcpy for src->s == NULL\n"); + dst->s[0] = 0; return 0; } _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
