Module: kamailio
Branch: 5.8
Commit: 985869ce91fe8350bb43aa84099da77e5a5e332c
URL: 
https://github.com/kamailio/kamailio/commit/985869ce91fe8350bb43aa84099da77e5a5e332c

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-03-05T17:59:56+01:00

core: ut - pkg_str_dup() skip memcpy when dst->len is 0

(cherry picked from commit fc1004506098e302cba9819179b76a62e245aba0)
(cherry picked from commit 52e23ef0ccd9940aadd0cf47deef77706ca37cdb)

---

Modified: src/core/ut.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/985869ce91fe8350bb43aa84099da77e5a5e332c.diff
Patch: 
https://github.com/kamailio/kamailio/commit/985869ce91fe8350bb43aa84099da77e5a5e332c.patch

---

diff --git a/src/core/ut.h b/src/core/ut.h
index 93aba97dc4a..a21d9330993 100644
--- a/src/core/ut.h
+++ b/src/core/ut.h
@@ -998,6 +998,11 @@ static inline int pkg_str_dup(str *dst, const str *src)
                return -1;
        }
 
+       if(dst->len == 0) {
+               dst->s[0] = 0;
+               return 0;
+       }
+
        /* avoid memcpy from NULL source - undefined behaviour */
        if(src->s == NULL) {
                LM_WARN("pkg_str_dup fallback; skip memcpy for src->s == 
NULL\n");

_______________________________________________
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!

Reply via email to