Fix #5885: Check for division by zero

This commit is contained in:
Armin Novak 2020-02-27 10:10:04 +01:00
parent f484b20787
commit 5e4603d0b7
1 changed files with 11 additions and 4 deletions

View File

@ -442,7 +442,7 @@ static UINT rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp
return rdpsnd_virtual_channel_write(rdpsnd, pdu); return rdpsnd_virtual_channel_write(rdpsnd, pdu);
} }
static BOOL rdpsnd_detect_overrun(rdpsndPlugin* rdpsnd, AUDIO_FORMAT* format, size_t size) static BOOL rdpsnd_detect_overrun(rdpsndPlugin* rdpsnd, const AUDIO_FORMAT* format, size_t size)
{ {
UINT32 bpf; UINT32 bpf;
UINT32 now; UINT32 now;
@ -451,9 +451,16 @@ static BOOL rdpsnd_detect_overrun(rdpsndPlugin* rdpsnd, AUDIO_FORMAT* format, si
UINT32 remainingDuration; UINT32 remainingDuration;
UINT32 maxDuration; UINT32 maxDuration;
bpf = format->nChannels * format->wBitsPerSample / 8; if (!rdpsnd || !format)
duration = (UINT32)(1000 * size / bpf / format->nSamplesPerSec); return FALSE;
totalDuration = (UINT32)(1000 * rdpsnd->totalPlaySize / bpf / format->nSamplesPerSec);
audio_format_print(WLog_Get(TAG), WLOG_DEBUG, format);
bpf = format->nChannels * format->wBitsPerSample * format->nSamplesPerSec / 8;
if (bpf == 0)
return FALSE;
duration = (UINT32)(1000 * size / bpf);
totalDuration = (UINT32)(1000 * rdpsnd->totalPlaySize / bpf);
now = GetTickCountPrecise(); now = GetTickCountPrecise();
if (rdpsnd->startPlayTime == 0) if (rdpsnd->startPlayTime == 0)
{ {