Module: kamailio
Branch: 6.0
Commit: 37be2e73af0c0e975ef9d55bb18644a21a2dbf69
URL: 
https://github.com/kamailio/kamailio/commit/37be2e73af0c0e975ef9d55bb18644a21a2dbf69

Author: Victor Seva <[email protected]>
Committer: Victor Seva <[email protected]>
Date: 2026-05-04T10:55:38+02:00

ims_ipsec_pcscf: Fix problems with double mem free

fix #4670

same logic as 91c5ca751799db4f25a28a495350cc97f7c2f390

(cherry picked from commit c7f290cc92760365af81f99c290a905d4e5c609c)
(cherry picked from commit d04659303e7fbfb55d0884dedc6dde6ceac7c51b)

---

Modified: src/modules/ims_ipsec_pcscf/sec_agree.c

---

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

---

diff --git a/src/modules/ims_ipsec_pcscf/sec_agree.c 
b/src/modules/ims_ipsec_pcscf/sec_agree.c
index 4ad62a69d6a..1b977e9c2d6 100644
--- a/src/modules/ims_ipsec_pcscf/sec_agree.c
+++ b/src/modules/ims_ipsec_pcscf/sec_agree.c
@@ -293,14 +293,22 @@ static security_t *parse_sec_agree(struct hdr_field *h)
                shm_free(params->sec_header.s);
 
                if(params->type == SECURITY_IPSEC && params->data.ipsec) {
-                       shm_free(params->data.ipsec->ealg.s);
-                       shm_free(params->data.ipsec->r_ealg.s);
-                       shm_free(params->data.ipsec->ck.s);
-                       shm_free(params->data.ipsec->alg.s);
-                       shm_free(params->data.ipsec->r_alg.s);
-                       shm_free(params->data.ipsec->ik.s);
-                       shm_free(params->data.ipsec->prot.s);
-                       shm_free(params->data.ipsec->mod.s);
+                       if(params->data.ipsec->ealg.s)
+                               shm_free(params->data.ipsec->ealg.s);
+                       if(params->data.ipsec->r_ealg.s)
+                               shm_free(params->data.ipsec->r_ealg.s);
+                       if(params->data.ipsec->ck.s)
+                               shm_free(params->data.ipsec->ck.s);
+                       if(params->data.ipsec->alg.s)
+                               shm_free(params->data.ipsec->alg.s);
+                       if(params->data.ipsec->r_alg.s)
+                               shm_free(params->data.ipsec->r_alg.s);
+                       if(params->data.ipsec->ik.s)
+                               shm_free(params->data.ipsec->ik.s);
+                       if(params->data.ipsec->prot.s)
+                               shm_free(params->data.ipsec->prot.s);
+                       if(params->data.ipsec->mod.s)
+                               shm_free(params->data.ipsec->mod.s);
                        shm_free(params->data.ipsec);
                }
 

_______________________________________________
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