[Freeswitch-svn] [commit] r8474 - freeswitch/trunk/src

Freeswitch SVN mikej at freeswitch.org
Mon May 19 15:57:27 EDT 2008


Author: mikej
Date: Mon May 19 15:57:27 2008
New Revision: 8474

Modified:
   freeswitch/trunk/src/switch_ivr_play_say.c

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

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Mon May 19 15:57:27 2008
@@ -676,7 +676,7 @@
 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 @@
 	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 @@
 		
 	}
 
-
 	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 @@
 		asis = 1;
 	}
 
+	switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
 	write_frame.data = abuf;
 	write_frame.buflen = FILE_STARTSAMPLES;
 
@@ -1000,7 +997,6 @@
 		if (done || olen <= 0) {
 			break;
 		}
-		
 
 		if (!asis) {
 			if (fh->speed > 2) {
@@ -1156,7 +1152,7 @@
 
 
  end:
-	free(abuf);
+	switch_safe_free(abuf);
 
 	switch_core_session_reset(session, SWITCH_TRUE);
 	return status;



More information about the Freeswitch-svn mailing list