Project "FreeSWITCH Source" received a push.

branch: master updated

       via: 02234ae87db5fcca0168a140b5800618de65d3d9 (commit)
      from: 145884c94ce9bcb25aa14d45e6d689b0d4af75ed (commit)


= COMMIT LOG ===========================================================
committer: Anthony Minessale
comments: 
fix file leaks in mod_commandline_tts

diff --git a/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c b/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c
index 6b261f1..0f3bc41 100644
--- a/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c
+++ b/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c
@@ -120,6 +120,11 @@ static switch_status_t tts_commandline_speech_close(switch_speech_handle_t *sh,
 	tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
 	assert(info != NULL);
 
+	if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
+		switch_core_file_close(info->fh);
+		unlink(info->file);
+	}
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -130,6 +135,11 @@ static switch_status_t tts_commandline_speech_feed_tts(switch_speech_handle_t *s
 
 	assert(info != NULL);
 
+	if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
+		switch_core_file_close(info->fh);
+		unlink(info->file);
+	}
+
 	message = switch_core_strdup(sh->memory_pool, globals.command);
 
 	tmp = switch_util_quote_shell_arg(text);
@@ -152,7 +162,7 @@ static switch_status_t tts_commandline_speech_feed_tts(switch_speech_handle_t *s
 	}
 
 	if (switch_core_file_open(info->fh, info->file, 0,	//number_of_channels,
-							  0,	//samples_per_second,
+							  info->rate,	//samples_per_second,
 							  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file: %s\n", info->file);
 		return SWITCH_STATUS_FALSE;
@@ -171,11 +181,14 @@ static switch_status_t tts_commandline_speech_read_tts(switch_speech_handle_t *s
 	assert(info != NULL);
 
 	if (switch_core_file_read(info->fh, data, &my_datalen) != SWITCH_STATUS_SUCCESS) {
-		*datalen = my_datalen * 2;
+		switch_core_file_close(info->fh);
+		unlink(info->file);
 		return SWITCH_STATUS_FALSE;
 	}
 	*datalen = my_datalen * 2;
 	if (datalen == 0) {
+		switch_core_file_close(info->fh);
+		unlink(info->file);
 		return SWITCH_STATUS_BREAK;
 	} else {
 		return SWITCH_STATUS_SUCCESS;
========================================================================

Summary of changes:
 .../mod_tts_commandline/mod_tts_commandline.c      |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email
For more info, see http://blog.chomperstomp.com/?p=630 --
FreeSWITCH Source