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

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

ims_registrar_pcscf: Fix problems with double mem free

fix #4671

same logic as 91c5ca751799db4f25a28a495350cc97f7c2f390

---

Modified: src/modules/ims_registrar_pcscf/sec_agree.c

---

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