Skip to content

Commit

Permalink
rtpengine: avoid serializing if rtpengine ctx was not created
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Nov 29, 2023
1 parent ae9e51e commit d832370
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions modules/rtpengine/rtpengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -4449,13 +4449,17 @@ static int rtpengine_api_copy_delete(struct rtp_relay_session *sess,

static int rtpengine_api_copy_serialize(void *_ctx, bin_packet_t *packet)
{
return bin_push_str(packet, (str *)_ctx);
str str_empty = str_init("");
if (!_ctx)
return bin_push_str(packet, &str_empty);
else
return bin_push_str(packet, (str *)_ctx);
}

static int rtpengine_api_copy_deserialize(void **_ctx, bin_packet_t *packet)
{
str to_tag;
if (bin_pop_str(packet, &to_tag) < 0)
if (bin_pop_str(packet, &to_tag) < 0 || to_tag.len == 0)
return -1;

*_ctx = rtpengine_new_subs(&to_tag);
Expand Down

0 comments on commit d832370

Please sign in to comment.