<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7100">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 0b50f68..bcc4877 100644<br>--- a/res/res_pjsip_history.c<br>+++ b/res/res_pjsip_history.c<br>@@ -707,10 +707,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>@@ -747,10 +750,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>@@ -961,7 +967,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>@@ -1037,7 +1045,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>@@ -1058,6 +1070,7 @@<br> }<br> result = final->result;<br> ast_free(final);<br>+ AST_VECTOR_FREE(&stack);<br> <br> return result;<br> <br>@@ -1100,6 +1113,7 @@<br> <br> queue = build_expression_queue(a);<br> if (!queue) {<br>+ AST_VECTOR_PTR_FREE(output);<br> return NULL;<br> }<br> <br>@@ -1120,7 +1134,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/7100">change 7100</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/7100"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </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: 7100 </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>