Skip to content

Commit

Permalink
ims_usrloc_pcscf: Add new function free_security() which deallocates …
Browse files Browse the repository at this point in the history
…security_t parameter from a contact
  • Loading branch information
tdimitrov committed Dec 11, 2017
1 parent dd8f548 commit 99289be
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/modules/ims_usrloc_pcscf/pcontact.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 99289be

Please sign in to comment.