From 2f453eba35fa82b64929c2aac49d88c8be1a84d6 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 1 Oct 2011 08:37:42 -0700 Subject: Fix potential divide-by-0 --- OpenAL32/alBuffer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'OpenAL32/alBuffer.c') diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 768cc213..712acc94 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -844,9 +844,12 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pf { case AL_SEC_LENGTH: ReadLock(&pBuffer->lock); - *pflValue = (pBuffer->size / - FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType)) / - (ALfloat)pBuffer->Frequency; + if(pBuffer->size != 0) + *pflValue = (pBuffer->size / + FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType)) / + (ALfloat)pBuffer->Frequency; + else + *pflValue = 0.0f; ReadUnlock(&pBuffer->lock); break; @@ -965,8 +968,11 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plVa case AL_SAMPLE_LENGTH: ReadLock(&pBuffer->lock); - *plValue = pBuffer->size / - FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType); + if(pBuffer->size != 0) + *plValue = pBuffer->size / + FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType); + else + *plValue = 0; ReadUnlock(&pBuffer->lock); break; -- cgit v1.2.3