Skip to content

Commit

Permalink
SDL_sound: Take a mutex lock and remove use of volitile keyword
Browse files Browse the repository at this point in the history
This is a 2nd attempt at fixing a Coverity issue #2996
It potentially fixes a data race (not sure if this is what Coverity saw)
Sound_FreeSample also takes a lock but SDL's mutex is recursive so this
should be fine.
  • Loading branch information
weirddan455 committed Oct 15, 2023
1 parent 22ee73b commit 1f1b022
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libs/decoders/SDL_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ int Sound_Quit(void)

BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0);

while (((volatile Sound_Sample *) sample_list) != NULL)
SDL_LockMutex(samplelist_mutex);
while (sample_list != NULL)
{
Sound_Sample *sample = sample_list;
Sound_FreeSample(sample); /* Updates sample_list. */
sample = NULL;
Sound_FreeSample(sample_list); /* Updates sample_list. */
}
SDL_UnlockMutex(samplelist_mutex);

initialized = 0;

Expand Down

0 comments on commit 1f1b022

Please sign in to comment.