summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-11-06 08:39:20 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-11-06 08:39:20 -0600
commit1479d2603eabbd34c9cf93daa99bbd683184094c (patch)
tree51dee20d09989e0913eae76783d77fcb5fb16ba8 /res
parent6e34cf6af7efd6810c46798a05f52d1e7405e67a (diff)
parent3bce5a9dfa0e30942cac097a3161ada9c5bf60ee (diff)
Merge "Stasis/ARI: Fix off-nominal path json memory leaks." into 13
Diffstat (limited to 'res')
-rw-r--r--res/ari/resource_asterisk.c7
-rw-r--r--res/ari/resource_sounds.c1
-rw-r--r--res/res_ari.c4
-rw-r--r--res/stasis/messaging.c4
4 files changed, 14 insertions, 2 deletions
diff --git a/res/ari/resource_asterisk.c b/res/ari/resource_asterisk.c
index 30684d276..dafe9a602 100644
--- a/res/ari/resource_asterisk.c
+++ b/res/ari/resource_asterisk.c
@@ -435,6 +435,10 @@ void ast_ari_asterisk_list_modules(struct ast_variable *headers,
struct ast_json *json;
json = ast_json_array_create();
+ if (!json) {
+ ast_ari_response_alloc_failed(response);
+ return;
+ }
ast_update_module_list_data(&process_module_list, NULL, json);
ast_ari_response_ok(response, json);
@@ -507,6 +511,7 @@ void ast_ari_asterisk_get_module(struct ast_variable *headers,
ast_ari_response_error(
response, 409, "Conflict",
"Module information could not be retrieved");
+ ast_json_unref(json);
return;
}
@@ -669,10 +674,12 @@ void ast_ari_asterisk_list_log_channels(struct ast_variable *headers,
if (res == AST_LOGGER_FAILURE) {
ast_ari_response_error(response, 500, "Internal Server Error",
"Response body is not valid");
+ ast_json_unref(json);
return;
} else if (res == AST_LOGGER_ALLOC_ERROR) {
ast_ari_response_error(response, 500, "Internal Server Error",
"Allocation Failed");
+ ast_json_unref(json);
return;
}
diff --git a/res/ari/resource_sounds.c b/res/ari/resource_sounds.c
index 5a523d387..76a4d9436 100644
--- a/res/ari/resource_sounds.c
+++ b/res/ari/resource_sounds.c
@@ -204,6 +204,7 @@ void ast_ari_sounds_list(struct ast_variable *headers,
if (!ast_json_array_size(sounds_blob)) {
ast_ari_response_error(response, 404, "Not Found", "No sounds found that matched the query");
+ ast_json_unref(sounds_blob);
return;
}
diff --git a/res/res_ari.c b/res/res_ari.c
index 1ac532735..e4b50ab11 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -983,9 +983,11 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
struct ast_str *buf = ast_str_create(512);
char *str = ast_json_dump_string_format(body, ast_ari_json_format());
- if (!buf) {
+ if (!buf || !str) {
ast_http_request_close_on_completion(ser);
ast_http_error(ser, 500, "Server Error", "Out of memory");
+ ast_json_free(str);
+ ast_free(buf);
goto request_failed;
}
diff --git a/res/stasis/messaging.c b/res/stasis/messaging.c
index 229a3a646..d2df3ff0c 100644
--- a/res/stasis/messaging.c
+++ b/res/stasis/messaging.c
@@ -266,6 +266,7 @@ static struct ast_json *msg_to_json(struct ast_msg *msg)
json_vars = ast_json_array_create();
if (!json_vars) {
+ ast_msg_var_iterator_destroy(it_vars);
return NULL;
}
@@ -274,7 +275,8 @@ static struct ast_json *msg_to_json(struct ast_msg *msg)
json_tuple = ast_json_pack("{s: s}", name, value);
if (!json_tuple) {
- ast_json_free(json_vars);
+ ast_json_unref(json_vars);
+ ast_msg_var_iterator_destroy(it_vars);
return NULL;
}