Skip to content

Commit

Permalink
dialog: fix mem leak generated by missing replies
Browse files Browse the repository at this point in the history
When cseq was to change generated replies, if those replies were never
generated (due to missing replies from UAC), the callback was leaking.
  • Loading branch information
razvancrainea committed Apr 15, 2019
1 parent 0d026b9 commit 13bceaf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modules/dialog/dlg_handlers.c
Expand Up @@ -909,6 +909,11 @@ static void dlg_seq_down_onreply_mod_cseq(struct cell* t, int type,
return;
}

static void free_final_cseq(void *cseq)
{
shm_free(cseq);
}

static void fix_final_cseq(struct cell *t,int type,
struct tmcb_params *param)
{
Expand All @@ -920,8 +925,6 @@ static void fix_final_cseq(struct cell *t,int type,
if (update_msg_cseq((struct sip_msg *)param->rpl,&cseq,0) != 0)
LM_ERR("failed to update CSEQ in msg\n");

shm_free(cseq.s);

return ;
}

Expand Down Expand Up @@ -1686,7 +1689,7 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)

if ( d_tmb.register_tmcb( req, 0, TMCB_RESPONSE_FWDED,
fix_final_cseq,
(void*)final_cseq, 0)<0 ) {
(void*)final_cseq, free_final_cseq)<0 ) {
LM_ERR("failed to register TMCB (2)\n");
}
}
Expand Down

0 comments on commit 13bceaf

Please sign in to comment.