From 99289bec4bceb0db3eb992a36e0e6d8c8ae94db4 Mon Sep 17 00:00:00 2001 From: Tsvetomir Dimitrov Date: Mon, 11 Dec 2017 15:20:14 +0000 Subject: [PATCH] ims_usrloc_pcscf: Add new function free_security() which deallocates security_t parameter from a contact --- src/modules/ims_usrloc_pcscf/pcontact.c | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/modules/ims_usrloc_pcscf/pcontact.c b/src/modules/ims_usrloc_pcscf/pcontact.c index fec8be5f60d..ff666f81037 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);