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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-06-18T07:04:27+02:00

domain: free memory on errors

---

Modified: src/modules/domain/hash.c

---

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

---

diff --git a/src/modules/domain/hash.c b/src/modules/domain/hash.c
index 1ed046f4da3..2b5c7caf174 100644
--- a/src/modules/domain/hash.c
+++ b/src/modules/domain/hash.c
@@ -102,16 +102,20 @@ int hash_table_attr_install(struct domain_list 
**hash_table, str *did,
        np = (struct domain_list *)shm_malloc(sizeof(struct domain_list));
        if(np == NULL) {
                LM_ERR("no shm memory left for domain list\n");
-               if(type == 2)
-                       shm_free(attr->name.s);
+               if(type == 2) {
+                       shm_free(attr->val.s.s);
+               }
+               shm_free(attr->name.s);
                shm_free(attr);
                return -1;
        }
        np->did.s = (char *)shm_malloc(did->len);
        if(np->did.s == NULL) {
                LM_ERR("no shm memory left for did\n");
-               if(type == 2)
-                       shm_free(attr->name.s);
+               if(type == 2) {
+                       shm_free(attr->val.s.s);
+               }
+               shm_free(attr->name.s);
                shm_free(attr);
                shm_free(np);
                return -1;
@@ -150,6 +154,7 @@ int hash_table_install(struct domain_list **hash_table, str 
*did, str *domain)
        np->domain.s = (char *)shm_malloc(domain->len);
        if(np->domain.s == NULL) {
                LM_ERR("no shared memory for domain\n");
+               shm_free(np->did.s);
                shm_free(np);
                return -1;
        }

_______________________________________________
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