<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7038">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">PBX: Handle errors from AST_VECTOR_APPEND.<br><br>This resolves potentials leaks on AST_VECTOR_APPEND error in:<br>* ast_context_add_include2<br>* ast_context_add_switch2<br>* ast_context_add_ignorepat2<br><br>Change-Id: Ib60e95c4f622fa3b832d87227c0523a695d736b6<br>---<br>M main/pbx.c<br>1 file changed, 15 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/38/7038/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/pbx.c b/main/pbx.c<br>index 2366b72..b5602b5 100644<br>--- a/main/pbx.c<br>+++ b/main/pbx.c<br>@@ -6692,7 +6692,11 @@<br>       }<br> <br>  /* ... include new context into context list, unlock, return */<br>-      AST_VECTOR_APPEND(&con->includes, new_include);<br>+       if (AST_VECTOR_APPEND(&con->includes, new_include)) {<br>+         include_free(new_include);<br>+           ast_unlock_context(con);<br>+             return -1;<br>+   }<br>     ast_verb(3, "Including context '%s' in context '%s'\n",<br>             ast_get_include_name(new_include), ast_get_context_name(con));<br> <br>@@ -6754,7 +6758,11 @@<br>     }<br> <br>  /* ... sw new context into context list, unlock, return */<br>-   AST_VECTOR_APPEND(&con->alts, new_sw);<br>+        if (AST_VECTOR_APPEND(&con->alts, new_sw)) {<br>+          sw_free(new_sw);<br>+             ast_unlock_context(con);<br>+             return -1;<br>+   }<br> <br>  ast_verb(3, "Including switch '%s/%s' in context '%s'\n",<br>           ast_get_switch_name(new_sw), ast_get_switch_data(new_sw), ast_get_context_name(con));<br>@@ -6842,7 +6850,11 @@<br>                         return -1;<br>            }<br>     }<br>-    AST_VECTOR_APPEND(&con->ignorepats, ignorepat);<br>+       if (AST_VECTOR_APPEND(&con->ignorepats, ignorepat)) {<br>+         ignorepat_free(ignorepat);<br>+           ast_unlock_context(con);<br>+             return -1;<br>+   }<br>     ast_unlock_context(con);<br> <br>   return 0;<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7038">change 7038</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/7038"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib60e95c4f622fa3b832d87227c0523a695d736b6 </div>
<div style="display:none"> Gerrit-Change-Number: 7038 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>