Skip to content

Commit 70a34b9

Browse files
committed
tm: fix bavp leaks in case of error
Thanks go to Mickael Marrache for spotting and debugging
1 parent dcd3ec4 commit 70a34b9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

modules/tm/t_fwd.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,17 @@ static int add_uac( struct cell *t, struct sip_msg *request, str *uri,
422422
}
423423
error01:
424424
post_print_uac_request( request, uri, next_hop);
425+
if (ret < 0) {
426+
/* destroy all the bavps added, the path vector and the destination,
427+
* since this branch will never be properly added to
428+
* the UAC list, otherwise we'll have memory leaks - razvanc */
429+
if (t->uac[branch].user_avps)
430+
destroy_avp_list(&t->uac[branch].user_avps);
431+
if (t->uac[branch].path_vec.s)
432+
shm_free(t->uac[branch].path_vec.s);
433+
if (t->uac[branch].duri.s)
434+
shm_free(t->uac[branch].duri.s);
435+
}
425436
error:
426437
return ret;
427438
}

0 commit comments

Comments
 (0)