From 0cd61fd197394bbbc867f1df87ea2f951f49822d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 27 Jan 2018 23:07:29 -0800 Subject: Don't allocate more effect slots than allowed --- OpenAL32/alAuxEffectSlot.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenAL32/alAuxEffectSlot.c') diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 70025409..f5362e94 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -84,6 +84,7 @@ static inline ALeffect *LookupEffect(ALCdevice *device, ALuint id) AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { + ALCdevice *device; ALCcontext *context; ALeffectslot **tmpslots = NULL; ALsizei cur; @@ -96,7 +97,14 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo SETERR_GOTO(context, AL_INVALID_VALUE, done, "Generating %d effect slots", n); tmpslots = al_malloc(DEF_ALIGN, sizeof(ALeffectslot*)*n); + device = context->Device; LockEffectSlotList(context); + if(device->AuxiliaryEffectSlotMax - VECTOR_SIZE(context->EffectSlotList) > (ALuint)n) + { + UnlockEffectSlotList(context); + SETERR_GOTO(context, AL_OUT_OF_MEMORY, done, "Exceeding %u auxiliary effect slot limit", + device->AuxiliaryEffectSlotMax); + } for(cur = 0;cur < n;cur++) { ALeffectslotPtr *iter = VECTOR_BEGIN(context->EffectSlotList); -- cgit v1.2.3