[mod_tts_commandline, mod_sndfile] fix crash on file not found
This commit is contained in:
parent
7f63483138
commit
60746cc07c
|
@ -186,13 +186,17 @@ 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) {
|
||||
switch_core_file_close(info->fh);
|
||||
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
|
||||
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);
|
||||
if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
|
||||
switch_core_file_close(info->fh);
|
||||
}
|
||||
unlink(info->file);
|
||||
return SWITCH_STATUS_BREAK;
|
||||
} else {
|
||||
|
@ -205,7 +209,7 @@ static void tts_commandline_speech_flush_tts(switch_speech_handle_t *sh)
|
|||
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
|
||||
assert(info != NULL);
|
||||
|
||||
if (info->fh != NULL && info->fh->file_interface != NULL) {
|
||||
if (info->fh != NULL && info->fh->file_interface != NULL && switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
|
||||
switch_core_file_close(info->fh);
|
||||
}
|
||||
if (switch_file_exists(info->file, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
|
|
|
@ -267,7 +267,9 @@ static switch_status_t sndfile_file_close(switch_file_handle_t *handle)
|
|||
{
|
||||
sndfile_context *context = handle->private_info;
|
||||
|
||||
sf_close(context->handle);
|
||||
if (context) {
|
||||
sf_close(context->handle);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue