Module: kamailio
Branch: 6.0
Commit: 73a87dd6c19e79232597a13b6ccb844211512558
URL: 
https://github.com/kamailio/kamailio/commit/73a87dd6c19e79232597a13b6ccb844211512558

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

ims_registrar_pcscf: Fix problems with double mem free

fix #4671

same logic as 91c5ca751799db4f25a28a495350cc97f7c2f390

(cherry picked from commit 722c06b3efc53ccb369ce812c685c7d069508187)
(cherry picked from commit 66e0b5075dc741095bf3439e76d25833f8f82e52)

---

Modified: src/modules/ims_registrar_pcscf/sec_agree.c

---

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

---

diff --git a/src/modules/ims_registrar_pcscf/sec_agree.c 
b/src/modules/ims_registrar_pcscf/sec_agree.c
index c65f45cf38b..3b24467f911 100644
--- a/src/modules/ims_registrar_pcscf/sec_agree.c
+++ b/src/modules/ims_registrar_pcscf/sec_agree.c
@@ -217,14 +217,22 @@ static security_t *parse_sec_agree(struct hdr_field *h)
                shm_free(params->sec_header.s);
                shm_free(params->data.ipsec);
                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