<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7059">View Change</a></p><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, 16 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/59/7059/1</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 b0bcf3c..35b1b43 100644<br>--- a/res/stasis/app.c<br>+++ b/res/stasis/app.c<br>@@ -588,6 +588,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>@@ -613,11 +614,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 d398bb6..f0714fd 100644<br>--- a/res/stasis/messaging.c<br>+++ b/res/stasis/messaging.c<br>@@ -457,7 +457,10 @@<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>+ /* BUGBUG should we clear both refs and NULL sub so we return error? */<br>+ ao2_ref(sub, -1);<br>+ }<br> ast_rwlock_unlock(&tech_subscriptions_lock);<br> }<br> <br>@@ -485,7 +488,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/7059">change 7059</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/7059"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I8dd5385b9f50a5cadf2b1d16efecffd6ddb4db4a </div>
<div style="display:none"> Gerrit-Change-Number: 7059 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>