aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-07-26 04:54:27 -0700
committerChris Robinson <[email protected]>2016-07-26 04:54:27 -0700
commitd2eb866abeb699394a35610b4764c8e42acc71b5 (patch)
tree2c90ee7b93900f07e283a7bab0ea65210f32c546
parentb047eda1cbd9c8c1345c610b7ac236867b908cc6 (diff)
Avoid a NULL deref when creating 0 auxiliary effect slots
-rw-r--r--OpenAL32/alAuxEffectSlot.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 796eec5b..db084e5a 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -42,7 +42,6 @@ extern inline void UnlockEffectSlotsWrite(ALCcontext *context);
extern inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id);
extern inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id);
-static void AddEffectSlotList(ALCcontext *Context, ALeffectslot *first, ALeffectslot *last);
static void RemoveEffectSlotList(ALCcontext *Context, const ALeffectslot *slot);
@@ -97,12 +96,19 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
aluInitEffectPanning(slot);
if(!first) first = slot;
- if(last) ATOMIC_STORE(&last->next, slot);
+ if(last) ATOMIC_STORE(&last->next, slot, almemory_order_relaxed);
last = slot;
effectslots[cur] = slot->id;
}
- AddEffectSlotList(context, first, last);
+ if(last != NULL)
+ {
+ ALeffectslot *root = ATOMIC_LOAD(&context->ActiveAuxSlotList);
+ do {
+ ATOMIC_STORE(&last->next, root, almemory_order_relaxed);
+ } while(!ATOMIC_COMPARE_EXCHANGE_WEAK(ALeffectslot*, &context->ActiveAuxSlotList,
+ &root, first));
+ }
done:
ALCcontext_DecRef(context);
@@ -415,15 +421,6 @@ done:
}
-static void AddEffectSlotList(ALCcontext *context, ALeffectslot *start, ALeffectslot *last)
-{
- ALeffectslot *root = ATOMIC_LOAD(&context->ActiveAuxSlotList);
- do {
- ATOMIC_STORE(&last->next, root, almemory_order_relaxed);
- } while(!ATOMIC_COMPARE_EXCHANGE_WEAK(ALeffectslot*, &context->ActiveAuxSlotList,
- &root, start));
-}
-
static void RemoveEffectSlotList(ALCcontext *context, const ALeffectslot *slot)
{
ALCdevice *device = context->Device;