Skip to content

Commit

Permalink
tm: free new uac dlg in case of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Jan 5, 2024
1 parent 8038fba commit ef45b7b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
21 changes: 15 additions & 6 deletions src/modules/tm/dlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,17 +333,25 @@ int new_dlg_uac(str *_cid, str *_ltag, unsigned int _lseq, str *_luri,
memset(res, 0, sizeof(dlg_t));

/* Make a copy of Call-ID */
if(str_duplicate(&res->id.call_id, _cid) < 0)
if(str_duplicate(&res->id.call_id, _cid) < 0) {
free_dlg(res);
return -3;
}
/* Make a copy of local tag (usually From tag) */
if(str_duplicate(&res->id.loc_tag, _ltag) < 0)
if(str_duplicate(&res->id.loc_tag, _ltag) < 0) {
free_dlg(res);
return -4;
}
/* Make a copy of local URI (usually From) */
if(str_duplicate(&res->loc_uri, _luri) < 0)
if(str_duplicate(&res->loc_uri, _luri) < 0) {
free_dlg(res);
return -5;
}
/* Make a copy of remote URI (usually To) */
if(str_duplicate(&res->rem_uri, _ruri) < 0)
if(str_duplicate(&res->rem_uri, _ruri) < 0) {
free_dlg(res);
return -6;
}
/* Make a copy of local sequence (usually CSeq) */
res->loc_seq.value = _lseq;
/* And mark it as set */
Expand All @@ -353,8 +361,9 @@ int new_dlg_uac(str *_cid, str *_ltag, unsigned int _lseq, str *_luri,

if(calculate_hooks(*_d) < 0) {
LM_ERR("error while calculating hooks\n");
/* FIXME: free everything here */
shm_free(res);
/* free everything here */
free_dlg(res);
*_d = NULL;
return -2;
}
#ifdef DIALOG_CALLBACKS
Expand Down
1 change: 0 additions & 1 deletion src/modules/tm/rpc_uac.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ static int get_hfblock(str *uri, struct hdr_field *hf, int proto,
if(!append_str_list(sock_name->s, sock_name->len, &last,
&total_len))
goto error;
/* inefficient - FIXME --andrei*/
if(!append_str_list(":", 1, &last, &total_len))
goto error;
if(!append_str_list(portname->s, portname->len, &last,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/tm/t_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ int t_relay_to(
/* transaction previously found (E_SCRIPT) and msg==ACK
=> ack to neg. reply or ack to local trans.
=> process it and exit */
/* FIXME: there's no way to distinguish here between acks to
/* - there's no way to distinguish here between acks to
local trans. and neg. acks */
/* in normal operation we should never reach this point, if we
do WARN(), it might hide some real bug (apart from possibly
Expand Down
2 changes: 1 addition & 1 deletion src/modules/tm/t_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static int matching_3261(struct sip_msg *p_msg, struct cell **trans,
* which is interested in it (E2EACK* callbacks)
* if ret==3 => partial match => we should at least
* make sure the ACK is not for a negative reply
* (FIXME: ret==3 should never happen, it's a bug catch
* (note: ret==3 should never happen, it's a bug catch
* case)*/
if(unlikely(ret == 1))
goto found;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/tm/tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ static int fixup_hostport2proxy(void **param, int param_no)
}
s.s = host;
s.len = strlen(host);
proxy = mk_proxy(&s, port, 0); /* FIXME: udp or tcp? */
proxy = mk_proxy(&s, port, 0);
if(proxy == 0) {
LM_ERR("bad host name in URI <%s>\n", host);
return E_BAD_ADDRESS;
Expand Down Expand Up @@ -2572,7 +2572,7 @@ int t_check_trans(struct sip_msg *msg)
if(msg->REQ_METHOD == METHOD_ACK) {
/* ack to neg. reply or ack to local trans.
* => process it and end the script */
/* FIXME: there's no way to distinguish here
/* - there's no way to distinguish here
* between acks to local trans. and neg. acks */
if(unlikely(has_tran_tmcbs(t, TMCB_ACK_NEG_IN)))
run_trans_callbacks(
Expand Down
3 changes: 1 addition & 2 deletions src/modules/tm/uac.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,7 @@ int ack_local_uac(struct cell *trans, str *hdrs, str *body)

ret = 0;
fin:
/* TODO: ugly! */
/* FIXME: the T had been obtain by t_lookup_ident()'ing for it, so, it is
/* note: the T had been obtain by t_lookup_ident()'ing for it, so, it is
* ref-counted. The t_unref() can not be used, as it requests a valid SIP
* message (all available might be the reply, but if AS goes wrong and
* tries to ACK before the final reply is received, we still have to
Expand Down

0 comments on commit ef45b7b

Please sign in to comment.