Properly limit the max number of effect slots to 2^31 - 1

This commit is contained in:
Chris Robinson 2018-03-04 14:00:28 -08:00
parent 5133fe5115
commit 19281868dc
2 changed files with 3 additions and 9 deletions

View File

@ -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(

View File

@ -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);