FS-6282 mod_rayo: fix memory leak in previous commit

This commit is contained in:
Chris Rienzo 2014-03-06 23:30:31 -05:00
parent 2ad7aa23bc
commit 455941d369
3 changed files with 23 additions and 24 deletions

View 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");
}

View 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);
}
/**

View 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);