<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7083">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
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_pubsub: Fix multiple leaks on failure to append vectors.<br><br>Change-Id: I68ece0073ea79667ca41eb10405f516f1d30d482<br>---<br>M res/res_pjsip_pubsub.c<br>1 file changed, 23 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c<br>index e2c6f6c..81fc69e 100644<br>--- a/res/res_pjsip_pubsub.c<br>+++ b/res/res_pjsip_pubsub.c<br>@@ -938,7 +938,9 @@<br> }<br> ast_debug(2, "Subscription to leaf resource %s resulted in success. Adding to parent %s\n",<br> resource, parent->resource);<br>- AST_VECTOR_APPEND(&parent->children, current);<br>+ if (AST_VECTOR_APPEND(&parent->children, current)) {<br>+ tree_node_destroy(current);<br>+ }<br> } else {<br> ast_debug(2, "Subscription to leaf resource %s resulted in error response %d\n",<br> resource, resp);<br>@@ -953,7 +955,9 @@<br> build_node_children(endpoint, handler, child_list, current, visited);<br> if (AST_VECTOR_SIZE(¤t->children) > 0) {<br> ast_debug(1, "List %s had no successful children.\n", resource);<br>- AST_VECTOR_APPEND(&parent->children, current);<br>+ if (AST_VECTOR_APPEND(&parent->children, current)) {<br>+ tree_node_destroy(current);<br>+ }<br> } else {<br> ast_debug(2, "List %s had successful children. Adding to parent %s\n",<br> resource, parent->resource);<br>@@ -1216,6 +1220,10 @@<br> if (AST_VECTOR_APPEND(&sub->children, child)) {<br> ast_debug(1, "Child subscription to resource %s could not be appended\n",<br> child_node->resource);<br>+ destroy_subscription(child);<br>+ /* Have to release tree here too because a ref was added<br>+ * to child that destroy_subscription() doesn't release. */<br>+ ao2_cleanup(tree);<br> }<br> }<br> <br>@@ -2161,7 +2169,9 @@<br> bp->part->body = body;<br> pj_list_insert_before(&bp->part->hdr, bp->cid);<br> <br>- AST_VECTOR_APPEND(parts, bp);<br>+ if (AST_VECTOR_APPEND(parts, bp)) {<br>+ ast_free(bp);<br>+ }<br> }<br> <br> /*!<br>@@ -2222,6 +2232,7 @@<br> <br> /* This can happen if issuing partial state and no children of the list have changed state */<br> if (AST_VECTOR_SIZE(&body_parts) == 0) {<br>+ free_body_parts(&body_parts);<br> return NULL;<br> }<br> <br>@@ -2229,6 +2240,7 @@<br> <br> rlmi_part = build_rlmi_body(pool, sub, &body_parts, use_full_state);<br> if (!rlmi_part) {<br>+ free_body_parts(&body_parts);<br> return NULL;<br> }<br> pjsip_multipart_add_part(pool, multipart, rlmi_part);<br>@@ -4662,7 +4674,10 @@<br> ast_log(LOG_WARNING, "Ignoring duplicated list item '%s'\n", item);<br> continue;<br> }<br>- if (AST_VECTOR_APPEND(&list->items, ast_strdup(item))) {<br>+<br>+ item = ast_strdup(item);<br>+ if (!item || AST_VECTOR_APPEND(&list->items, item)) {<br>+ ast_free(item);<br> return -1;<br> }<br> }<br>@@ -4798,7 +4813,10 @@<br> ast_copy_string(list->event, event, sizeof(list->event));<br> <br> for (i = 0; i < num_resources; ++i) {<br>- if (AST_VECTOR_APPEND(&list->items, ast_strdup(resources[i]))) {<br>+ char *resource = ast_strdup(resources[i]);<br>+<br>+ if (!resource || AST_VECTOR_APPEND(&list->items, resource)) {<br>+ ast_free(resource);<br> return -1;<br> }<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7083">change 7083</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/7083"/><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: I68ece0073ea79667ca41eb10405f516f1d30d482 </div>
<div style="display:none"> Gerrit-Change-Number: 7083 </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: George Joseph <gjoseph@digium.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>