summaryrefslogtreecommitdiff
path: root/res/ari
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2014-01-12 22:24:27 +0000
committerJoshua Colp <jcolp@digium.com>2014-01-12 22:24:27 +0000
commit8585340b8768562bbffc0cfe51b7a59f197cd8a0 (patch)
treecabf6d29832d0606f66729ff84b4e5741cf24d6f /res/ari
parent373965dbff734b96132f61741838d6797c4a1876 (diff)
res_ari: Fix various memory leaks.
This change fixes a few memory leaks that were found based on a mailing list post. 1. Some JSON response messages were never freed. This was caused by the documentation stating that message references were stolen when in reality they were not. The code now follows the documentation and usage has been updated. 2. HTTP response headers were never freed. 3. The variable list for wildcards paths was never freed. (closes issue ASTERISK-23128) Reported by: Kenneth Watson (on list) Review: https://reviewboard.asterisk.org/r/3119/ ........ Merged revisions 405325 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405326 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/ari')
-rw-r--r--res/ari/resource_applications.c9
-rw-r--r--res/ari/resource_bridges.c4
-rw-r--r--res/ari/resource_channels.c4
-rw-r--r--res/ari/resource_device_states.c4
-rw-r--r--res/ari/resource_endpoints.c4
-rw-r--r--res/ari/resource_playbacks.c4
-rw-r--r--res/ari/resource_recordings.c8
7 files changed, 18 insertions, 19 deletions
diff --git a/res/ari/resource_applications.c b/res/ari/resource_applications.c
index aef939005..85a631a02 100644
--- a/res/ari/resource_applications.c
+++ b/res/ari/resource_applications.c
@@ -68,15 +68,14 @@ void ast_ari_applications_list(struct ast_variable *headers,
return;
}
-
- ast_ari_response_ok(response, json);
+ ast_ari_response_ok(response, ast_json_ref(json));
}
void ast_ari_applications_get(struct ast_variable *headers,
struct ast_ari_applications_get_args *args,
struct ast_ari_response *response)
{
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
json = stasis_app_to_json(args->application_name);
@@ -113,7 +112,7 @@ void ast_ari_applications_subscribe(struct ast_variable *headers,
switch (res) {
case STASIS_ASR_OK:
- ast_ari_response_ok(response, json);
+ ast_ari_response_ok(response, ast_json_ref(json));
break;
case STASIS_ASR_APP_NOT_FOUND:
ast_ari_response_error(response, 404, "Not Found",
@@ -152,7 +151,7 @@ void ast_ari_applications_unsubscribe(struct ast_variable *headers,
switch (res) {
case STASIS_ASR_OK:
- ast_ari_response_ok(response, json);
+ ast_ari_response_ok(response, ast_json_ref(json));
break;
case STASIS_ASR_APP_NOT_FOUND:
ast_ari_response_error(response, 404, "Not Found",
diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c
index 16f26279b..9f6562b50 100644
--- a/res/ari/resource_bridges.c
+++ b/res/ari/resource_bridges.c
@@ -411,7 +411,7 @@ void ast_ari_bridges_play(struct ast_variable *headers,
play_channel = NULL;
control = NULL;
- ast_ari_response_created(response, playback_url, json);
+ ast_ari_response_created(response, playback_url, ast_json_ref(json));
}
void ast_ari_bridges_record(struct ast_variable *headers,
@@ -566,7 +566,7 @@ void ast_ari_bridges_record(struct ast_variable *headers,
record_channel = NULL;
control = NULL;
- ast_ari_response_created(response, recording_url, json);
+ ast_ari_response_created(response, recording_url, ast_json_ref(json));
}
void ast_ari_bridges_start_moh(struct ast_variable *headers,
diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c
index c6900f1b2..e6322a37c 100644
--- a/res/ari/resource_channels.c
+++ b/res/ari/resource_channels.c
@@ -362,7 +362,7 @@ void ast_ari_channels_play(struct ast_variable *headers,
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
RAII_VAR(struct stasis_app_playback *, playback, NULL, ao2_cleanup);
RAII_VAR(char *, playback_url, NULL, ast_free);
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
const char *language;
ast_assert(response != NULL);
@@ -434,7 +434,7 @@ void ast_ari_channels_record(struct ast_variable *headers,
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
RAII_VAR(char *, recording_url, NULL, ast_free);
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
RAII_VAR(struct stasis_app_recording_options *, options, NULL,
ao2_cleanup);
RAII_VAR(char *, uri_encoded_name, NULL, ast_free);
diff --git a/res/ari/resource_device_states.c b/res/ari/resource_device_states.c
index 50b876740..621910e1c 100644
--- a/res/ari/resource_device_states.c
+++ b/res/ari/resource_device_states.c
@@ -35,7 +35,7 @@ void ast_ari_device_states_list(
struct ast_ari_device_states_list_args *args,
struct ast_ari_response *response)
{
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
if (!(json = stasis_app_device_states_to_json())) {
ast_ari_response_error(response, 500,
@@ -50,7 +50,7 @@ void ast_ari_device_states_get(struct ast_variable *headers,
struct ast_ari_device_states_get_args *args,
struct ast_ari_response *response)
{
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
if (!(json = stasis_app_device_state_to_json(
args->device_name, ast_device_state(args->device_name)))) {
diff --git a/res/ari/resource_endpoints.c b/res/ari/resource_endpoints.c
index 7dab25b9c..2f47b1a1a 100644
--- a/res/ari/resource_endpoints.c
+++ b/res/ari/resource_endpoints.c
@@ -158,7 +158,7 @@ void ast_ari_endpoints_get(struct ast_variable *headers,
struct ast_ari_endpoints_get_args *args,
struct ast_ari_response *response)
{
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
RAII_VAR(struct ast_endpoint_snapshot *, snapshot, NULL, ao2_cleanup);
snapshot = ast_endpoint_latest_snapshot(args->tech, args->resource);
@@ -174,5 +174,5 @@ void ast_ari_endpoints_get(struct ast_variable *headers,
return;
}
- ast_ari_response_ok(response, ast_json_ref(json));
+ ast_ari_response_ok(response, json);
}
diff --git a/res/ari/resource_playbacks.c b/res/ari/resource_playbacks.c
index 0dbfc0545..3ef6710ac 100644
--- a/res/ari/resource_playbacks.c
+++ b/res/ari/resource_playbacks.c
@@ -35,7 +35,7 @@ void ast_ari_playbacks_get(struct ast_variable *headers,
struct ast_ari_response *response)
{
RAII_VAR(struct stasis_app_playback *, playback, NULL, ao2_cleanup);
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
playback = stasis_app_playback_find_by_id(args->playback_id);
if (playback == NULL) {
@@ -51,7 +51,7 @@ void ast_ari_playbacks_get(struct ast_variable *headers,
return;
}
- ast_ari_response_ok(response, ast_json_ref(json));
+ ast_ari_response_ok(response, json);
}
void ast_ari_playbacks_stop(struct ast_variable *headers,
struct ast_ari_playbacks_stop_args *args,
diff --git a/res/ari/resource_recordings.c b/res/ari/resource_recordings.c
index 418e3be63..abde4f0c0 100644
--- a/res/ari/resource_recordings.c
+++ b/res/ari/resource_recordings.c
@@ -76,7 +76,7 @@ void ast_ari_recordings_get_stored(struct ast_variable *headers,
{
RAII_VAR(struct stasis_app_stored_recording *, recording, NULL,
ao2_cleanup);
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
recording = stasis_app_stored_recording_find_by_name(
args->recording_name);
@@ -93,7 +93,7 @@ void ast_ari_recordings_get_stored(struct ast_variable *headers,
return;
}
- ast_ari_response_ok(response, ast_json_ref(json));
+ ast_ari_response_ok(response, json);
}
void ast_ari_recordings_delete_stored(struct ast_variable *headers,
@@ -142,7 +142,7 @@ void ast_ari_recordings_get_live(struct ast_variable *headers,
struct ast_ari_response *response)
{
RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
- RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ struct ast_json *json;
recording = stasis_app_recording_find_by_name(args->recording_name);
if (recording == NULL) {
@@ -158,7 +158,7 @@ void ast_ari_recordings_get_live(struct ast_variable *headers,
return;
}
- ast_ari_response_ok(response, ast_json_ref(json));
+ ast_ari_response_ok(response, json);
}
static void control_recording(const char *name,