Skip to content

Commit

Permalink
rtpengine: do not specify interfaces for non-offer/answer
Browse files Browse the repository at this point in the history
Avoid getting bogus `no more memory` errors when trying to specify in
in/out interface when `direction` node is NULL.

Close #2880

(cherry picked from commit bbb6f31)
  • Loading branch information
razvancrainea committed Oct 13, 2022
1 parent 3781adb commit 8cdc3e3
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions modules/rtpengine/rtpengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1896,18 +1896,22 @@ static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg,
}

if (iniface.len != 0 && outiface.len != 0) {
bitem = bencode_str(bencode_item_buffer(ng_flags->direction), &iniface);
if (!bitem) {
err = "no more memory";
goto error;
}
BCHECK(bencode_list_add(ng_flags->direction, bitem));
bitem = bencode_str(bencode_item_buffer(ng_flags->direction), &outiface);
if (!bitem) {
err = "no more memory";
goto error;
if (ng_flags->direction) {
bitem = bencode_str(bencode_item_buffer(ng_flags->direction), &iniface);
if (!bitem) {
err = iniface.s;
goto error;
}
BCHECK(bencode_list_add(ng_flags->direction, bitem));
bitem = bencode_str(bencode_item_buffer(ng_flags->direction), &outiface);
if (!bitem) {
err = "no more memory";
goto error;
}
BCHECK(bencode_list_add(ng_flags->direction, bitem));
} else {
LM_DBG("cannot set interfaces for non-offer/answer commands\n");
}
BCHECK(bencode_list_add(ng_flags->direction, bitem));
} else if (iniface.len) {
LM_ERR("in-iface value without out-iface\n");
return -1;
Expand Down

0 comments on commit 8cdc3e3

Please sign in to comment.