aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-01-01 07:33:48 -0800
committerChris Robinson <[email protected]>2014-01-01 07:33:48 -0800
commit7d94e9c52fc7023e7ef7ca036de02b6131ecc376 (patch)
tree53be273463e8e2621ab04899c7fb03932a24378a /Alc
parent0a5a08c0fb942e4db407f6eccc86c091dc7c362f (diff)
Don't allow soundfonts with existing presets in alLoadSoundfontSOFT
Diffstat (limited to 'Alc')
-rw-r--r--Alc/midi/sf2load.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/Alc/midi/sf2load.c b/Alc/midi/sf2load.c
index 1733bab2..43f960c6 100644
--- a/Alc/midi/sf2load.c
+++ b/Alc/midi/sf2load.c
@@ -1322,35 +1322,25 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context)
GenModList_Destruct(&gzone);
IDList_Destruct(&fsids);
}
+ if(pids.ids_size > 0)
{
- ALsizei count = pids.ids_size;
- ALsfpreset **presets;
+ ALsfpreset **presets = NULL;
+ ALCdevice *device = context->Device;
- if(count == 0)
- presets = NULL;
- else
- {
- ALCdevice *device = context->Device;
-
- presets = calloc(count, sizeof(presets[0]));
- if(!presets)
- SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, error);
+ presets = calloc(pids.ids_size, sizeof(presets[0]));
+ if(!presets)
+ SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, error);
- for(i = 0;i < count;i++)
- {
- if(!(presets[i]=LookupPreset(device, pids.ids[i])))
- SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, error);
- }
+ for(i = 0;i < pids.ids_size;i++)
+ {
+ if(!(presets[i]=LookupPreset(device, pids.ids[i])))
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, error);
}
- for(i = 0;i < count;i++)
+ for(i = 0;i < pids.ids_size;i++)
IncrementRef(&presets[i]->ref);
-
presets = ExchangePtr((XchgPtr*)&soundfont->Presets, presets);
- count = ExchangeInt(&soundfont->NumPresets, count);
- for(i = 0;i < count;i++)
- DecrementRef(&presets[i]->ref);
free(presets);
}