prevent obscure divide by zero code path

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15413 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-11-10 23:50:58 +00:00
parent ebe4bebfdc
commit a58fd5ae15
2 changed files with 7 additions and 7 deletions

View File

@ -1158,7 +1158,7 @@ static switch_status_t create_file(switch_core_session_t *session, vm_profile_t
got_file = 1; got_file = 1;
} }
if (limit && (*message_len = fh.samples_out / fh.samplerate) < profile->min_record_len) { if (limit && (*message_len = fh.samples_out / fh.samplerate ? fh.samplerate : 8000) < profile->min_record_len) {
if (unlink(file_path) != 0) { if (unlink(file_path) != 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Failed to delete file [%s]\n", file_path); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Failed to delete file [%s]\n", file_path);
} }

View File

@ -53,6 +53,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
if (!fh->samplerate) {
if (!(fh->samplerate = rate)) {
fh->samplerate = 8000;
}
}
if (zstr(file_path)) { if (zstr(file_path)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Filename\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Filename\n");
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
@ -135,12 +141,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
fh->handler = switch_core_strdup(fh->memory_pool, rhs); fh->handler = switch_core_strdup(fh->memory_pool, rhs);
} }
if (!fh->samplerate) {
if (!(fh->samplerate = rate)) {
fh->samplerate = 8000;
}
}
if (channels) { if (channels) {
fh->channels = channels; fh->channels = channels;
} else { } else {