<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7060">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
Richard Mudgett: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_stasis: Fix multiple leaks.<br><br>* res/stasis/app.c JSON passed to app_send needs to be released.<br>* res/stasis_message.c: objects leak if vector append fails.<br><br>Change-Id: I8dd5385b9f50a5cadf2b1d16efecffd6ddb4db4a<br>---<br>M res/stasis/app.c<br>M res/stasis/messaging.c<br>2 files changed, 17 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/stasis/app.c b/res/stasis/app.c<br>index 7d88c1b..1e885c6 100644<br>--- a/res/stasis/app.c<br>+++ b/res/stasis/app.c<br>@@ -591,6 +591,7 @@<br> {<br> RAII_VAR(struct ast_endpoint_snapshot *, snapshot, NULL, ao2_cleanup);<br> struct ast_json *json_endpoint;<br>+ struct ast_json *message;<br> struct stasis_app *app = pvt;<br> char *tech;<br> char *resource;<br>@@ -616,11 +617,15 @@<br> return -1;<br> }<br> <br>- app_send(app, ast_json_pack("{s: s, s: o, s: o, s: o}",<br>+ message = ast_json_pack("{s: s, s: o, s: o, s: o}",<br> "type", "TextMessageReceived",<br> "timestamp", ast_json_timeval(ast_tvnow(), NULL),<br> "endpoint", json_endpoint,<br>- "message", ast_json_ref(json_msg)));<br>+ "message", ast_json_ref(json_msg));<br>+ if (message) {<br>+ app_send(app, message);<br>+ ast_json_unref(message);<br>+ }<br> <br> return 0;<br> }<br>diff --git a/res/stasis/messaging.c b/res/stasis/messaging.c<br>index d2df3ff..979b687 100644<br>--- a/res/stasis/messaging.c<br>+++ b/res/stasis/messaging.c<br>@@ -459,7 +459,11 @@<br> ao2_link(endpoint_subscriptions, sub);<br> } else {<br> ast_rwlock_wrlock(&tech_subscriptions_lock);<br>- AST_VECTOR_APPEND(&tech_subscriptions, ao2_bump(sub));<br>+ if (AST_VECTOR_APPEND(&tech_subscriptions, ao2_bump(sub))) {<br>+ /* Release the ao2_bump that was for the vector and allocation references. */<br>+ ao2_ref(sub, -2);<br>+ sub = NULL;<br>+ }<br> ast_rwlock_unlock(&tech_subscriptions_lock);<br> }<br> <br>@@ -487,7 +491,11 @@<br> ao2_unlock(sub);<br> return -1;<br> }<br>- AST_VECTOR_APPEND(&sub->applications, tuple);<br>+ if (AST_VECTOR_APPEND(&sub->applications, tuple)) {<br>+ ao2_ref(tuple, -1);<br>+ ao2_unlock(sub);<br>+ return -1;<br>+ }<br> ao2_unlock(sub);<br> <br> ast_debug(3, "App '%s' subscribed to messages from endpoint '%s'\n", app_name, endpoint ? ast_endpoint_get_id(endpoint) : "-- ALL --");<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7060">change 7060</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/7060"/><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: I8dd5385b9f50a5cadf2b1d16efecffd6ddb4db4a </div>
<div style="display:none"> Gerrit-Change-Number: 7060 </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>