<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6984">View Change</a></p><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;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/84/6984/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/sorcery.c b/main/sorcery.c<br>index 713b038..1bdf2c2 100644<br>--- a/main/sorcery.c<br>+++ b/main/sorcery.c<br>@@ -1597,6 +1597,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 30684d2..dafe9a6 100644<br>--- a/res/ari/resource_asterisk.c<br>+++ b/res/ari/resource_asterisk.c<br>@@ -435,6 +435,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>@@ -507,6 +511,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>@@ -669,10 +674,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 5a523d3..76a4d94 100644<br>--- a/res/ari/resource_sounds.c<br>+++ b/res/ari/resource_sounds.c<br>@@ -204,6 +204,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 1ac5327..e4b50ab 100644<br>--- a/res/res_ari.c<br>+++ b/res/res_ari.c<br>@@ -983,9 +983,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 229a3a6..d2df3ff 100644<br>--- a/res/stasis/messaging.c<br>+++ b/res/stasis/messaging.c<br>@@ -266,6 +266,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>@@ -274,7 +275,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/6984">change 6984</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/6984"/><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: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Id569c624c426e3b22a99936473c730592d8b83fb </div>
<div style="display:none"> Gerrit-Change-Number: 6984 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>