]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Revert "Revert "res_rtp_asterisk: Free payload when error on insertion to data buffer""
authorJoshua Colp <jcolp@sangoma.com>
Wed, 29 Apr 2020 20:42:43 +0000 (15:42 -0500)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Thu, 30 Apr 2020 15:03:08 +0000 (10:03 -0500)
This reverts commit fe3dc091b57bf16ba62e185fe05f77069062a3b1.

Reason for revert: This will be merged once 16.8-cert1 is released.

Change-Id: I5c29f96a70ed7e1fa146a69e7b48bfe31cbee929

main/data_buffer.c
res/res_rtp_asterisk.c

index cfc323c680d5ac8d5266501e952471aced937c4b..85e79711c4a69389eb3d712e628650e89de64452 100644 (file)
@@ -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) {
index e3f4e544410b0c64eeb89aa06f4dd8f35bf89103..134eebc07c18ca9965d43752fd0028c4a29e47d0 100644 (file)
@@ -4897,7 +4897,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);
+                               }
                        }
                }
 
@@ -7847,7 +7849,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