don't leak on switch_ivr_play_file when using phrase or say. Found by Klockwork (www.klocwork.com)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8474 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-05-19 19:57:27 +00:00
parent cc5074183b
commit 76d98d76b4

View File

@ -676,7 +676,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
int16_t *abuf;
int16_t *abuf = NULL;
switch_dtmf_t dtmf = {0};
uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
uint32_t ilen = 0;
@ -699,8 +699,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
const char *prebuf;
const char *alt = NULL;
switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
switch_channel_pre_answer(channel);
prefix = switch_channel_get_variable(channel, "sound_prefix");
@ -760,12 +758,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
}
if (!prefix) {
prefix = SWITCH_GLOBAL_dirs.base_dir;
}
if (!strstr(file, SWITCH_URL_SEPARATOR)) {
if (!switch_is_file_path(file)) {
file = switch_core_session_sprintf(session, "%s%s%s", prefix, SWITCH_PATH_SEPARATOR, file);
@ -809,6 +805,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
asis = 1;
}
switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
write_frame.data = abuf;
write_frame.buflen = FILE_STARTSAMPLES;
@ -1000,7 +997,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
if (done || olen <= 0) {
break;
}
if (!asis) {
if (fh->speed > 2) {
@ -1156,7 +1152,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
end:
free(abuf);
switch_safe_free(abuf);
switch_core_session_reset(session, SWITCH_TRUE);
return status;