]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
don't leak on error conditions in mod_local_stream. Found by Klockwork (www.klocwork...
authorMichael Jerris <mike@jerris.com>
Wed, 21 May 2008 22:12:41 +0000 (22:12 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 21 May 2008 22:12:41 +0000 (22:12 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8513 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/formats/mod_local_stream/mod_local_stream.c

index f966cd73ac48b1818a03019805100c4f5a23d53b..caa84ccd3f8b1c1e96e62fb1d85a87a21645964b 100644 (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);
        }