<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7039">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">RTP Engine: Deal with errors returned from AST_VECTOR_REPLACE.<br><br>Check for errors from AST_VECTOR_REPLACE and clean memory if needed.<br><br>Change-Id: I124d15cc1d645f85a72a1279f623c1993b304b0b<br>---<br>M main/rtp_engine.c<br>1 file changed, 17 insertions(+), 7 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/rtp_engine.c b/main/rtp_engine.c<br>index 0aed8e9..2431ffc 100644<br>--- a/main/rtp_engine.c<br>+++ b/main/rtp_engine.c<br>@@ -802,7 +802,10 @@<br> ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_rx, payload),<br> "cleaning up rx mapping vector element about to be replaced");<br> }<br>- AST_VECTOR_REPLACE(&codecs->payload_mapping_rx, payload, new_type);<br>+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_rx, payload, new_type)) {<br>+ ao2_ref(new_type, -1);<br>+ return;<br>+ }<br> <br> payload_mapping_rx_clear_primary(codecs, new_type);<br> }<br>@@ -924,7 +927,10 @@<br> ao2_t_cleanup(AST_VECTOR_GET(&dest->payload_mapping_tx, idx),<br> "cleaning up tx mapping vector element about to be replaced");<br> }<br>- AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, type);<br>+ if (AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, type)) {<br>+ ao2_ref(type, -1);<br>+ continue;<br>+ }<br> <br> if (instance && instance->engine && instance->engine->payload_set) {<br> ao2_lock(instance);<br>@@ -1038,9 +1044,10 @@<br> ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload),<br> "cleaning up replaced tx payload type");<br> }<br>- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type);<br> <br>- if (instance && instance->engine && instance->engine->payload_set) {<br>+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type)) {<br>+ ao2_ref(new_type, -1);<br>+ } else if (instance && instance->engine && instance->engine->payload_set) {<br> ao2_lock(instance);<br> instance->engine->payload_set(instance, payload, new_type->asterisk_format, new_type->format, new_type->rtp_code);<br> ao2_unlock(instance);<br>@@ -1116,9 +1123,10 @@<br> ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, pt),<br> "cleaning up replaced tx payload type");<br> }<br>- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type);<br> <br>- if (instance && instance->engine && instance->engine->payload_set) {<br>+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type)) {<br>+ ao2_ref(new_type, -1);<br>+ } else if (instance && instance->engine && instance->engine->payload_set) {<br> ao2_lock(instance);<br> instance->engine->payload_set(instance, pt, new_type->asterisk_format, new_type->format, new_type->rtp_code);<br> ao2_unlock(instance);<br>@@ -1215,7 +1223,9 @@<br> if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {<br> ao2_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload));<br> }<br>- AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type);<br>+ if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type)) {<br>+ ao2_ref(type, -1);<br>+ }<br> } else {<br> ao2_ref(type, -1);<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7039">change 7039</a>. To unsubscribe, 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/7039"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I124d15cc1d645f85a72a1279f623c1993b304b0b </div>
<div style="display:none"> Gerrit-Change-Number: 7039 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>