<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7099">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: 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;">res_pjsip_history: Fix multiple leaks on vector append failure.<br><br>Change-Id: I41e8d5183ace284095cc721f3b1fb32ade3f940f<br>---<br>M res/res_pjsip_history.c<br>1 file changed, 23 insertions(+), 7 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_history.c b/res/res_pjsip_history.c<br>index 4e7dbd0..ed374d6 100644<br>--- a/res/res_pjsip_history.c<br>+++ b/res/res_pjsip_history.c<br>@@ -705,10 +705,13 @@<br>   pj_sockaddr_cp(&entry->dst, &tdata->tp_info.dst_addr);<br> <br>       ast_mutex_lock(&history_lock);<br>-   AST_VECTOR_APPEND(&vector_history, entry);<br>+       if (AST_VECTOR_APPEND(&vector_history, entry)) {<br>+         ao2_ref(entry, -1);<br>+          entry = NULL;<br>+        }<br>     ast_mutex_unlock(&history_lock);<br> <br>-      if (log_level != -1) {<br>+       if (log_level != -1 && entry) {<br>               char line[256];<br> <br>            sprint_list_entry(entry, line, sizeof(line));<br>@@ -745,10 +748,13 @@<br>  }<br> <br>  ast_mutex_lock(&history_lock);<br>-   AST_VECTOR_APPEND(&vector_history, entry);<br>+       if (AST_VECTOR_APPEND(&vector_history, entry)) {<br>+         ao2_ref(entry, -1);<br>+          entry = NULL;<br>+        }<br>     ast_mutex_unlock(&history_lock);<br> <br>-      if (log_level != -1) {<br>+       if (log_level != -1 && entry) {<br>               char line[256];<br> <br>            sprint_list_entry(entry, line, sizeof(line));<br>@@ -959,7 +965,9 @@<br> <br>                 /* If this is not an operator, push it to the stack */<br>                if (!it_queue->op) {<br>-                      AST_VECTOR_APPEND(&stack, it_queue);<br>+                     if (AST_VECTOR_APPEND(&stack, it_queue)) {<br>+                               goto error;<br>+                  }<br>                     continue;<br>             }<br> <br>@@ -1035,7 +1043,11 @@<br>          if (!result) {<br>                        goto error;<br>           }<br>-            AST_VECTOR_APPEND(&stack, result);<br>+               if (AST_VECTOR_APPEND(&stack, result)) {<br>+                 expression_token_free(result);<br>+<br>+                    goto error;<br>+          }<br>     }<br> <br>  /*<br>@@ -1056,6 +1068,7 @@<br>     }<br>     result = final->result;<br>    ast_free(final);<br>+     AST_VECTOR_FREE(&stack);<br> <br>       return result;<br> <br>@@ -1098,6 +1111,7 @@<br> <br>   queue = build_expression_queue(a);<br>    if (!queue) {<br>+                AST_VECTOR_PTR_FREE(output);<br>          return NULL;<br>  }<br> <br>@@ -1118,7 +1132,9 @@<br>           } else if (!res) {<br>                    continue;<br>             } else {<br>-                     AST_VECTOR_APPEND(output, ao2_bump(entry));<br>+                  if (AST_VECTOR_APPEND(output, ao2_bump(entry))) {<br>+                            ao2_cleanup(entry);<br>+                  }<br>             }<br>     }<br>     ast_mutex_unlock(&history_lock);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7099">change 7099</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/7099"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: I41e8d5183ace284095cc721f3b1fb32ade3f940f </div>
<div style="display:none"> Gerrit-Change-Number: 7099 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </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: Richard Mudgett <rmudgett@digium.com> </div>