diff --git a/main/data_buffer.c b/main/data_buffer.c index cfc323c680d..85e79711c4a 100644 --- a/main/data_buffer.c +++ b/main/data_buffer.c @@ -254,7 +254,7 @@ int ast_data_buffer_put(struct ast_data_buffer *buffer, size_t pos, void *payloa AST_LIST_TRAVERSE_SAFE_END; if (inserted == -1) { - return 0; + return -1; } if (!inserted) { diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index 4fc42177cea..5dd5d355f16 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -4991,7 +4991,9 @@ static int rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame *fr if (payload) { payload->size = packet_len; memcpy(payload->buf, rtpheader, packet_len); - ast_data_buffer_put(rtp->send_buffer, rtp->seqno, payload); + if (ast_data_buffer_put(rtp->send_buffer, rtp->seqno, payload) == -1) { + ast_free(payload); + } } } @@ -7938,7 +7940,9 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc payload->size = res; memcpy(payload->buf, rtpheader, res); - ast_data_buffer_put(rtp->recv_buffer, seqno, payload); + if (ast_data_buffer_put(rtp->recv_buffer, seqno, payload) == -1) { + ast_free(payload); + } /* If this sequence number is removed that means we had a gap and this packet has filled it in * some. Since it was part of the gap we will have already added any other missing sequence numbers