<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7047">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_ari_events: Fix JSON leak in stasis_app_message_handler.<br><br>The only time we didn't leak the JSON object is when no client was<br>connected and we successfully added the message to the queue.<br><br>Change-Id: I82696df8fe723b3365c15c3f7089501da8daa892<br>---<br>M res/ari/resource_events.c<br>1 file changed, 9 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/47/7047/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/ari/resource_events.c b/res/ari/resource_events.c<br>index 4be5d02..447af10 100644<br>--- a/res/ari/resource_events.c<br>+++ b/res/ari/resource_events.c<br>@@ -108,11 +108,14 @@<br>                         msg_application);<br>     } else if (!session->ws_session) {<br>                 /* If the websocket is NULL, the message goes to the queue */<br>-                AST_VECTOR_APPEND(&session->message_queue, message);<br>-          ast_log(LOG_WARNING,<br>-                         "Queued '%s' message for Stasis app '%s'; websocket is not ready\n",<br>-                               msg_type,<br>-                            msg_application);<br>+            if (!AST_VECTOR_APPEND(&session->message_queue, message)) {<br>+                   ast_log(LOG_WARNING,<br>+                                 "Queued '%s' message for Stasis app '%s'; websocket is not ready\n",<br>+                                       msg_type,<br>+                                    msg_application);<br>+                    /* This is the only path that we don't free message. */<br>+                  message = NULL;<br>+              }<br>     } else {<br>              if (stasis_app_get_debug_by_name(app_name)) {<br>                         char *str = ast_json_dump_string_format(message, ast_ari_json_format());<br>@@ -126,6 +129,7 @@<br>                 /* We are ready to publish the message */<br>             ast_ari_websocket_session_write(session->ws_session, message);<br>     }<br>+    ast_json_unref(message);<br> <br>   ao2_unlock(session);<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7047">change 7047</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/7047"/><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: I82696df8fe723b3365c15c3f7089501da8daa892 </div>
<div style="display:none"> Gerrit-Change-Number: 7047 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>