Merge "Stasis/ARI: Fix off-nominal path json memory leaks."
This commit is contained in:
commit
3c6fe0545a
5 changed files with 15 additions and 2 deletions
|
@ -1633,6 +1633,7 @@ struct ast_json *ast_sorcery_objectset_json_create(const struct ast_sorcery *sor
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (!object_type || !json) {
|
if (!object_type || !json) {
|
||||||
|
ast_json_unref(json);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -433,6 +433,10 @@ void ast_ari_asterisk_list_modules(struct ast_variable *headers,
|
||||||
struct ast_json *json;
|
struct ast_json *json;
|
||||||
|
|
||||||
json = ast_json_array_create();
|
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_update_module_list_data(&process_module_list, NULL, json);
|
||||||
|
|
||||||
ast_ari_response_ok(response, json);
|
ast_ari_response_ok(response, json);
|
||||||
|
@ -505,6 +509,7 @@ void ast_ari_asterisk_get_module(struct ast_variable *headers,
|
||||||
ast_ari_response_error(
|
ast_ari_response_error(
|
||||||
response, 409, "Conflict",
|
response, 409, "Conflict",
|
||||||
"Module information could not be retrieved");
|
"Module information could not be retrieved");
|
||||||
|
ast_json_unref(json);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,10 +672,12 @@ void ast_ari_asterisk_list_log_channels(struct ast_variable *headers,
|
||||||
if (res == AST_LOGGER_FAILURE) {
|
if (res == AST_LOGGER_FAILURE) {
|
||||||
ast_ari_response_error(response, 500, "Internal Server Error",
|
ast_ari_response_error(response, 500, "Internal Server Error",
|
||||||
"Response body is not valid");
|
"Response body is not valid");
|
||||||
|
ast_json_unref(json);
|
||||||
return;
|
return;
|
||||||
} else if (res == AST_LOGGER_ALLOC_ERROR) {
|
} else if (res == AST_LOGGER_ALLOC_ERROR) {
|
||||||
ast_ari_response_error(response, 500, "Internal Server Error",
|
ast_ari_response_error(response, 500, "Internal Server Error",
|
||||||
"Allocation Failed");
|
"Allocation Failed");
|
||||||
|
ast_json_unref(json);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,7 @@ void ast_ari_sounds_list(struct ast_variable *headers,
|
||||||
|
|
||||||
if (!ast_json_array_size(sounds_blob)) {
|
if (!ast_json_array_size(sounds_blob)) {
|
||||||
ast_ari_response_error(response, 404, "Not Found", "No sounds found that matched the query");
|
ast_ari_response_error(response, 404, "Not Found", "No sounds found that matched the query");
|
||||||
|
ast_json_unref(sounds_blob);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -984,9 +984,11 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
|
||||||
struct ast_str *buf = ast_str_create(512);
|
struct ast_str *buf = ast_str_create(512);
|
||||||
char *str = ast_json_dump_string_format(body, ast_ari_json_format());
|
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_request_close_on_completion(ser);
|
||||||
ast_http_error(ser, 500, "Server Error", "Out of memory");
|
ast_http_error(ser, 500, "Server Error", "Out of memory");
|
||||||
|
ast_json_free(str);
|
||||||
|
ast_free(buf);
|
||||||
goto request_failed;
|
goto request_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,7 @@ static struct ast_json *msg_to_json(struct ast_msg *msg)
|
||||||
|
|
||||||
json_vars = ast_json_array_create();
|
json_vars = ast_json_array_create();
|
||||||
if (!json_vars) {
|
if (!json_vars) {
|
||||||
|
ast_msg_var_iterator_destroy(it_vars);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +273,8 @@ static struct ast_json *msg_to_json(struct ast_msg *msg)
|
||||||
|
|
||||||
json_tuple = ast_json_pack("{s: s}", name, value);
|
json_tuple = ast_json_pack("{s: s}", name, value);
|
||||||
if (!json_tuple) {
|
if (!json_tuple) {
|
||||||
ast_json_free(json_vars);
|
ast_json_unref(json_vars);
|
||||||
|
ast_msg_var_iterator_destroy(it_vars);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue