Module: kamailio
Branch: master
Commit: fc1004506098e302cba9819179b76a62e245aba0
URL: 
https://github.com/kamailio/kamailio/commit/fc1004506098e302cba9819179b76a62e245aba0

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-01-17T07:53:09+01:00

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

---

Modified: src/core/ut.h

---

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

---

diff --git a/src/core/ut.h b/src/core/ut.h
index c4a495ab2ed..1f4c84daecd 100644
--- a/src/core/ut.h
+++ b/src/core/ut.h
@@ -1006,6 +1006,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