From 301a8ba3a403ece650790d015995a56f27718115 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 21 Sep 2010 14:41:43 -0700 Subject: Improve some range checks --- OpenAL32/alAuxEffectSlot.c | 6 ++++-- OpenAL32/alSource.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index d8ccaf71..9c5cf5fc 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -45,11 +45,13 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo Context = GetContextSuspended(); if(!Context) return; - if(n > 0) + if(n < 0) + alSetError(Context, AL_INVALID_VALUE); + else { ALCdevice *Device = Context->Device; - if(Context->EffectSlotMap.size+n <= (ALsizei)Device->AuxiliaryEffectSlotMax) + if((ALuint)n <= Device->AuxiliaryEffectSlotMax - Context->EffectSlotMap.size) { // Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots if(!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index c9051793..32e8c4da 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -62,7 +62,7 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources) if(!IsBadWritePtr((void*)sources, n * sizeof(ALuint))) { // Check that the requested number of sources can be generated - if((Context->SourceMap.size + n) <= (ALsizei)Device->MaxNoOfSources) + if((ALuint)n <= Device->MaxNoOfSources - Context->SourceMap.size) { ALenum err; -- cgit v1.2.3