don't leak on error conditions in mod_local_stream. Found by Klockwork (www.klocwork.com)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8513 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-05-21 22:12:41 +00:00
parent 2c19360e0d
commit 0bdd7007d0
1 changed files with 7 additions and 5 deletions

View File

@ -120,10 +120,9 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
if (switch_dir_open(&source->dir_handle, source->location, source->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't open directory: %s\n", source->location);
return NULL;
goto done;
}
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "open directory: %s\n", source->location);
switch_yield(1000000);
while(RUNNING) {
@ -181,11 +180,11 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
if (switch_core_timer_init(&timer, source->timer_name, source->interval, source->samples, source->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't start timer.\n");
return NULL;
switch_dir_close(source->dir_handle);
source->dir_handle = NULL;
goto done;
}
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Playing [%s] rate: %dhz\n", fname, source->rate);
while (RUNNING) {
switch_core_timer_next(&timer);
olen = source->samples;
@ -231,6 +230,9 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
source->dir_handle = NULL;
}
done:
switch_buffer_destroy(&audio_buffer);
if (fd > -1) {
close(fd);
}