Module: kamailio
Branch: master
Commit: 99289bec4bceb0db3eb992a36e0e6d8c8ae94db4
URL:
https://github.com/kamailio/kamailio/commit/99289bec4bceb0db3eb992a36e0e6d8…
Author: Tsvetomir Dimitrov <tsv.dimitrov(a)gmail.com>
Committer: Tsvetomir Dimitrov <tsv.dimitrov(a)gmail.com>
Date: 2017-12-11T15:26:42Z
ims_usrloc_pcscf: Add new function free_security() which deallocates security_t parameter
from a contact
---
Modified: src/modules/ims_usrloc_pcscf/pcontact.c
---
Diff:
https://github.com/kamailio/kamailio/commit/99289bec4bceb0db3eb992a36e0e6d8…
Patch:
https://github.com/kamailio/kamailio/commit/99289bec4bceb0db3eb992a36e0e6d8…
---
diff --git a/src/modules/ims_usrloc_pcscf/pcontact.c
b/src/modules/ims_usrloc_pcscf/pcontact.c
index fec8be5f60..ff666f8103 100644
--- a/src/modules/ims_usrloc_pcscf/pcontact.c
+++ b/src/modules/ims_usrloc_pcscf/pcontact.c
@@ -112,6 +112,38 @@ void free_ppublic(ppublic_t* _p)
shm_free(_p);
}
+void free_security(security_t* _p)
+{
+ if (!_p)
+ return;
+
+ shm_free(_p->sec_header.s);
+
+ switch (_p->type)
+ {
+ case SECURITY_IPSEC:
+ shm_free(_p->data.ipsec->ealg.s);
+ shm_free(_p->data.ipsec->r_ealg.s);
+ shm_free(_p->data.ipsec->ck.s);
+ shm_free(_p->data.ipsec->alg.s);
+ shm_free(_p->data.ipsec->r_alg.s);
+ shm_free(_p->data.ipsec->ik.s);
+ shm_free(_p->data.ipsec->prot.s);
+ shm_free(_p->data.ipsec->mod.s);
+
+ shm_free(_p->data.ipsec);
+ break;
+
+ case SECURITY_TLS:
+ shm_free(_p->data.tls);
+ break;
+
+ //default: Nothing to deallocate
+ }
+
+ shm_free(_p);
+}
+
int new_pcontact(struct udomain* _d, str* _contact, struct pcontact_info* _ci, struct
pcontact** _c)
{
int i, has_rinstance=0;
@@ -275,6 +307,10 @@ void free_pcontact(pcontact_t* _c) {
_c->num_service_routes = 0;
}
+ // free_security() checks for NULL ptr
+ free_security(_c->security_temp);
+ free_security(_c->security);
+
if (_c->rx_session_id.len > 0 && _c->rx_session_id.s)
shm_free(_c->rx_session_id.s);
shm_free(_c);