Skip to content

Commit

Permalink
siptrace: siptrace: fix memory leak in fake replies tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
grumvalski committed Apr 22, 2020
1 parent a59dbb7 commit c366b54
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/modules/siptrace/siptrace.c
Expand Up @@ -1569,6 +1569,7 @@ static void trace_onreply_out(struct cell *t, int type, struct tmcb_params *ps)
siptrace_data_t sto;
siptrace_info_t* info;
int faked = 0;
int parsed_f = 0;
struct sip_msg *msg;
struct sip_msg *req;
struct ip_addr to_ip;
Expand Down Expand Up @@ -1607,6 +1608,11 @@ static void trace_onreply_out(struct cell *t, int type, struct tmcb_params *ps)
if(msg == NULL || msg == FAKED_REPLY) {
msg = t->uas.request;
faked = 1;
/* check if from header has been already parsed.
* If not we have to parse it in pkg memory and free iit at the end.
*/
if (msg->from && msg->from->parsed != NULL)
parsed_f = 1;
}

if(sip_trace_msg_attrs(msg, &sto) < 0) {
Expand Down Expand Up @@ -1686,10 +1692,14 @@ static void trace_onreply_out(struct cell *t, int type, struct tmcb_params *ps)

if (info->uriState == STRACE_RAW_URI) {
LM_BUG("uriState must be either UNUSED or PARSED here! must be a bug! Message won't be traced!\n");
return;
goto end;
}

sip_trace_store(&sto, info->uriState == STRACE_PARSED_URI ? &info->u.dest_info : NULL, NULL);

end:
if (faked && parsed_f)
free_from(msg->from->parsed);
}

static void trace_tm_neg_ack_in(struct cell *t, int type, struct tmcb_params *ps)
Expand Down

0 comments on commit c366b54

Please sign in to comment.