From 19281868dce20d47344bd059b5f3c4af5264baaa Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 4 Mar 2018 14:00:28 -0800 Subject: [PATCH] Properly limit the max number of effect slots to 2^31 - 1 --- Alc/ALc.c | 2 ++ OpenAL32/alAuxEffectSlot.c | 10 +--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index c72a1833..554a4951 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -4139,6 +4139,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) ConfigValueUInt(deviceName, NULL, "slots", &device->AuxiliaryEffectSlotMax); if(device->AuxiliaryEffectSlotMax == 0) device->AuxiliaryEffectSlotMax = 64; + else device->AuxiliaryEffectSlotMax = minu(device->AuxiliaryEffectSlotMax, INT_MAX); if(ConfigValueInt(deviceName, NULL, "sends", &device->NumAuxSends)) device->NumAuxSends = clampi( @@ -4487,6 +4488,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN ConfigValueUInt(NULL, NULL, "slots", &device->AuxiliaryEffectSlotMax); if(device->AuxiliaryEffectSlotMax == 0) device->AuxiliaryEffectSlotMax = 64; + else device->AuxiliaryEffectSlotMax = minu(device->AuxiliaryEffectSlotMax, INT_MAX); if(ConfigValueInt(NULL, NULL, "sends", &device->NumAuxSends)) device->NumAuxSends = clampi( diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 6eb6187b..9ccfaa36 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -109,7 +109,6 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo ALCdevice *device; ALCcontext *context; ALsizei cur; - ALenum err; context = GetContextRef(); if(!context) return; @@ -131,6 +130,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo ALeffectslotPtr *iter = VECTOR_BEGIN(context->EffectSlotList); ALeffectslotPtr *end = VECTOR_END(context->EffectSlotList); ALeffectslot *slot = NULL; + ALenum err = AL_OUT_OF_MEMORY; for(;iter != end;iter++) { @@ -139,18 +139,10 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo } if(iter == end) { - if(VECTOR_SIZE(context->EffectSlotList) >= INT_MAX) - { - UnlockEffectSlotList(context); - - alDeleteAuxiliaryEffectSlots(cur, effectslots); - SETERR_GOTO(context, err, done, "Too many effect slot objects"); - } VECTOR_PUSH_BACK(context->EffectSlotList, NULL); iter = &VECTOR_BACK(context->EffectSlotList); } slot = al_calloc(16, sizeof(ALeffectslot)); - err = AL_OUT_OF_MEMORY; if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR) { al_free(slot);