<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7100">View Change</a></p><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, 20 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/00/7100/1</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..fef3bbc 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,7 +750,10 @@<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>@@ -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>@@ -1120,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/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: newchange </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: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>