<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6986">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  Matthew Fredrickson: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Stasis/ARI: Fix off-nominal path json memory leaks.<br><br>Change-Id: Id569c624c426e3b22a99936473c730592d8b83fb<br>---<br>M main/sorcery.c<br>M res/ari/resource_asterisk.c<br>M res/ari/resource_sounds.c<br>M res/res_ari.c<br>M res/stasis/messaging.c<br>5 files changed, 15 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/sorcery.c b/main/sorcery.c<br>index 6694167..01b7791 100644<br>--- a/main/sorcery.c<br>+++ b/main/sorcery.c<br>@@ -1633,6 +1633,7 @@<br>    int res = 0;<br> <br>       if (!object_type || !json) {<br>+         ast_json_unref(json);<br>                 return NULL;<br>  }<br> <br>diff --git a/res/ari/resource_asterisk.c b/res/ari/resource_asterisk.c<br>index e76eb02..5c6a35a 100644<br>--- a/res/ari/resource_asterisk.c<br>+++ b/res/ari/resource_asterisk.c<br>@@ -433,6 +433,10 @@<br>       struct ast_json *json;<br> <br>     json = ast_json_array_create();<br>+      if (!json) {<br>+         ast_ari_response_alloc_failed(response);<br>+             return;<br>+      }<br>     ast_update_module_list_data(&process_module_list, NULL, json);<br> <br>         ast_ari_response_ok(response, json);<br>@@ -505,6 +509,7 @@<br>             ast_ari_response_error(<br>                       response, 409, "Conflict",<br>                  "Module information could not be retrieved");<br>+              ast_json_unref(json);<br>                 return;<br>       }<br> <br>@@ -667,10 +672,12 @@<br>   if (res == AST_LOGGER_FAILURE) {<br>              ast_ari_response_error(response, 500, "Internal Server Error",<br>                      "Response body is not valid");<br>+             ast_json_unref(json);<br>                 return;<br>       } else if (res == AST_LOGGER_ALLOC_ERROR) {<br>           ast_ari_response_error(response, 500, "Internal Server Error",<br>                      "Allocation Failed");<br>+              ast_json_unref(json);<br>                 return;<br>       }<br> <br>diff --git a/res/ari/resource_sounds.c b/res/ari/resource_sounds.c<br>index 59ace5d..2cb35b6 100644<br>--- a/res/ari/resource_sounds.c<br>+++ b/res/ari/resource_sounds.c<br>@@ -202,6 +202,7 @@<br> <br>     if (!ast_json_array_size(sounds_blob)) {<br>              ast_ari_response_error(response, 404, "Not Found", "No sounds found that matched the query");<br>+            ast_json_unref(sounds_blob);<br>          return;<br>       }<br> <br>diff --git a/res/res_ari.c b/res/res_ari.c<br>index 5145499..7c12d39 100644<br>--- a/res/res_ari.c<br>+++ b/res/res_ari.c<br>@@ -984,9 +984,11 @@<br>               struct ast_str *buf = ast_str_create(512);<br>            char *str = ast_json_dump_string_format(body, ast_ari_json_format());<br> <br>-             if (!buf) {<br>+          if (!buf || !str) {<br>                   ast_http_request_close_on_completion(ser);<br>                    ast_http_error(ser, 500, "Server Error", "Out of memory");<br>+                       ast_json_free(str);<br>+                  ast_free(buf);<br>                        goto request_failed;<br>          }<br> <br>diff --git a/res/stasis/messaging.c b/res/stasis/messaging.c<br>index 8dfd996..d398bb6 100644<br>--- a/res/stasis/messaging.c<br>+++ b/res/stasis/messaging.c<br>@@ -264,6 +264,7 @@<br> <br>         json_vars = ast_json_array_create();<br>  if (!json_vars) {<br>+            ast_msg_var_iterator_destroy(it_vars);<br>                return NULL;<br>  }<br> <br>@@ -272,7 +273,8 @@<br> <br>          json_tuple = ast_json_pack("{s: s}", name, value);<br>          if (!json_tuple) {<br>-                   ast_json_free(json_vars);<br>+                    ast_json_unref(json_vars);<br>+                   ast_msg_var_iterator_destroy(it_vars);<br>                        return NULL;<br>          }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6986">change 6986</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/6986"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: Id569c624c426e3b22a99936473c730592d8b83fb </div>
<div style="display:none"> Gerrit-Change-Number: 6986 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.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: Matthew Fredrickson <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>