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

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

ims_ipsec_pcscf: Fix problems with double mem free

fix #4670

same logic as 91c5ca751799db4f25a28a495350cc97f7c2f390

---

Modified: src/modules/ims_ipsec_pcscf/sec_agree.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/c7f290cc92760365af81f99c290a905d4e5c609c.diff
Patch: 
https://github.com/kamailio/kamailio/commit/c7f290cc92760365af81f99c290a905d4e5c609c.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