]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6282 mod_rayo: fix memory leak in previous commit
authorChris Rienzo <chris@rienzo.com>
Fri, 7 Mar 2014 04:30:31 +0000 (23:30 -0500)
committerChris Rienzo <chris@rienzo.com>
Sun, 9 Mar 2014 15:41:01 +0000 (11:41 -0400)
src/mod/event_handlers/mod_rayo/rayo_cpa_component.c
src/mod/event_handlers/mod_rayo/rayo_output_component.c
src/mod/event_handlers/mod_rayo/rayo_record_component.c

index 1cd355683ebdeb5093c080ff2d01f5c6e63c7581..a73bb0daf8090588dbce68eadc9a82128d9124db 100644 (file)
@@ -287,6 +287,7 @@ iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg,
        component = switch_core_alloc(pool, sizeof(*component));
        component = CPA_COMPONENT(rayo_component_init((struct rayo_component *)component, pool, RAT_CALL_COMPONENT, "cpa", NULL, call, iks_find_attrib(iq, "from")));
        if (!component) {
+               switch_core_destroy_memory_pool(&pool);
                return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to create CPA entity");
        }
 
index 1817a5f34298686feb79bc5341f97099a09dbccb..c713450fd194cf826e8aaa96d37c80585d793b45 100644 (file)
@@ -69,20 +69,19 @@ static struct rayo_component *create_output_component(struct rayo_actor *actor,
        switch_core_new_memory_pool(&pool);
        output_component = switch_core_alloc(pool, sizeof(*output_component));
        output_component = OUTPUT_COMPONENT(rayo_component_init((struct rayo_component *)output_component, pool, type, "output", NULL, actor, client_jid));
-       if (!output_component) {
+       if (output_component) {
+               output_component->document = iks_copy(output);
+               output_component->start_offset_ms = iks_find_int_attrib(output, "start-offset");
+               output_component->repeat_interval_ms = iks_find_int_attrib(output, "repeat-interval");
+               output_component->repeat_times = iks_find_int_attrib(output, "repeat-times");
+               output_component->max_time_ms = iks_find_int_attrib(output, "max-time");
+               output_component->start_paused = iks_find_bool_attrib(output, "start-paused");
+               output_component->renderer = iks_find_attrib(output, "renderer");
+       } else {
                switch_core_destroy_memory_pool(&pool);
-               return NULL;
        }
 
-       output_component->document = iks_copy(output);
-       output_component->start_offset_ms = iks_find_int_attrib(output, "start-offset");
-       output_component->repeat_interval_ms = iks_find_int_attrib(output, "repeat-interval");
-       output_component->repeat_times = iks_find_int_attrib(output, "repeat-times");
-       output_component->max_time_ms = iks_find_int_attrib(output, "max-time");
-       output_component->start_paused = iks_find_bool_attrib(output, "start-paused");
-       output_component->renderer = iks_find_attrib(output, "renderer");
-
-       return (struct rayo_component *)output_component;
+       return RAYO_COMPONENT(output_component);
 }
 
 /**
index 6e1b1484ef1dd62798c9badbb50ad9f497c8829e..1f3f3a68500b742e76b3ac5b3bc1cd2fa27f111c 100644 (file)
@@ -170,22 +170,21 @@ static struct rayo_component *record_component_create(struct rayo_actor *actor,
 
        switch_core_new_memory_pool(&pool);
        record_component = switch_core_alloc(pool, sizeof(*record_component));
-       record_component = RECORD_COMPONENT(rayo_component_init(RAYO_COMPONENT(record_component), pool, type, "record", fs_file_path, actor, client_jid));
-       if (!record_component) {
+       record_component = RECORD_COMPONENT(rayo_component_init(RAYO_COMPONENT(record_component), pool, type, "record", fs_file_path, actor, client_jid));\
+       if (record_component) {
+               record_component->max_duration = iks_find_int_attrib(record, "max-duration");
+               record_component->initial_timeout = iks_find_int_attrib(record, "initial-timeout");
+               record_component->final_timeout = iks_find_int_attrib(record, "final-timeout");
+               record_component->direction = switch_core_strdup(RAYO_POOL(record_component), iks_find_attrib_soft(record, "direction"));
+               record_component->mix = iks_find_bool_attrib(record, "mix");
+               record_component->start_beep = iks_find_bool_attrib(record, "start-beep");
+               record_component->stop_beep = iks_find_bool_attrib(record, "stop-beep");
+               record_component->start_time = start_paused ? 0 : switch_micro_time_now();
+               record_component->local_file_path = switch_core_strdup(RAYO_POOL(record_component), local_file_path);
+       } else {
                switch_core_destroy_memory_pool(&pool);
-               return NULL;
        }
 
-       record_component->max_duration = iks_find_int_attrib(record, "max-duration");
-       record_component->initial_timeout = iks_find_int_attrib(record, "initial-timeout");
-       record_component->final_timeout = iks_find_int_attrib(record, "final-timeout");
-       record_component->direction = switch_core_strdup(RAYO_POOL(record_component), iks_find_attrib_soft(record, "direction"));
-       record_component->mix = iks_find_bool_attrib(record, "mix");
-       record_component->start_beep = iks_find_bool_attrib(record, "start-beep");
-       record_component->stop_beep = iks_find_bool_attrib(record, "stop-beep");
-       record_component->start_time = start_paused ? 0 : switch_micro_time_now();
-       record_component->local_file_path = switch_core_strdup(RAYO_POOL(record_component), local_file_path);
-
        switch_safe_free(local_file_path);
        switch_safe_free(fs_file_path);