<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7086">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, 18 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/86/7086/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 4e7dbd0..0627c60 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,7 +748,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>@@ -959,6 +965,7 @@<br> <br> /* If this is not an operator, push it to the stack */<br> if (!it_queue->op) {<br>+ /* BUGBUG: possible leak on failure? */<br> AST_VECTOR_APPEND(&stack, it_queue);<br> continue;<br> }<br>@@ -1035,7 +1042,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>@@ -1118,7 +1129,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/7086">change 7086</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/7086"/><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: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I41e8d5183ace284095cc721f3b1fb32ade3f940f </div>
<div style="display:none"> Gerrit-Change-Number: 7086 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>