<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14238">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_rtp_asterisk: Free payload when error on insertion to data buffer<br><br>When the ast_data_buffer_put rejects to add a packet, for example because<br>the buffer already contains a packet with the same sequence number, the<br>payload will never be freed, resulting in a memory leak.<br><br>The data buffer will now return an error if this situation occurs<br>allowing the caller to free the payload. The res_rtp_asterisk module<br>has also been updated to do this.<br><br>ASTERISK-28826<br><br>Change-Id: Ie6c49495d1c921d5f997651c7d0f79646f095cf1<br>---<br>M main/data_buffer.c<br>M res/res_rtp_asterisk.c<br>2 files changed, 7 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/data_buffer.c b/main/data_buffer.c</span><br><span>index cfc323c..85e7971 100644</span><br><span>--- a/main/data_buffer.c</span><br><span>+++ b/main/data_buffer.c</span><br><span>@@ -254,7 +254,7 @@</span><br><span> AST_LIST_TRAVERSE_SAFE_END;</span><br><span> </span><br><span> if (inserted == -1) {</span><br><span style="color: hsl(0, 100%, 40%);">- return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span> }</span><br><span> </span><br><span> if (!inserted) {</span><br><span>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c</span><br><span>index 4fc4217..5dd5d35 100644</span><br><span>--- a/res/res_rtp_asterisk.c</span><br><span>+++ b/res/res_rtp_asterisk.c</span><br><span>@@ -4991,7 +4991,9 @@</span><br><span> if (payload) {</span><br><span> payload->size = packet_len;</span><br><span> memcpy(payload->buf, rtpheader, packet_len);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_data_buffer_put(rtp->send_buffer, rtp->seqno, payload);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_data_buffer_put(rtp->send_buffer, rtp->seqno, payload) == -1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(payload);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -7938,7 +7940,9 @@</span><br><span> </span><br><span> payload->size = res;</span><br><span> memcpy(payload->buf, rtpheader, res);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_data_buffer_put(rtp->recv_buffer, seqno, payload);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_data_buffer_put(rtp->recv_buffer, seqno, payload) == -1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(payload);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> /* If this sequence number is removed that means we had a gap and this packet has filled it in</span><br><span> * some. Since it was part of the gap we will have already added any other missing sequence numbers</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14238">change 14238</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/14238"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 17 </div>
<div style="display:none"> Gerrit-Change-Id: Ie6c49495d1c921d5f997651c7d0f79646f095cf1 </div>
<div style="display:none"> Gerrit-Change-Number: 14238 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: nappsoft <infos@nappsoft.ch> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>