aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alBuffer.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-10-01 08:37:42 -0700
committerChris Robinson <[email protected]>2011-10-01 08:37:42 -0700
commit2f453eba35fa82b64929c2aac49d88c8be1a84d6 (patch)
tree2f8ea919508816680f9e2839665782bc9137e28a /OpenAL32/alBuffer.c
parent8b2e1fdd9a53d0145496b27f7ea0014124ce0d4a (diff)
Fix potential divide-by-0
Diffstat (limited to 'OpenAL32/alBuffer.c')
-rw-r--r--OpenAL32/alBuffer.c16
1 files changed, 11 insertions, 5 deletions
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;