From 0d71bf0ea4ea5f8de0601faece666e4c80a598a4 Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Sun, 5 Jan 2020 20:56:46 +0100 Subject: [PATCH] Silence Coverity issue in SDL_sound Coverity finds use after free on value pointed by sample_list, but fails to detect, that this is a global variable, that is being updated by Sound_FreeSample before freeing any memory. This code is obviously written with the purpose of freeing whole list, so there's nothing unexpected here - this is definitely a false positive finding. We could mark this issue as false-positive in Coverity, but I think it's better to avoid tripping it in the first place. --- src/libs/decoders/SDL_sound.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/decoders/SDL_sound.c b/src/libs/decoders/SDL_sound.c index f71650cf..18a0e70d 100644 --- a/src/libs/decoders/SDL_sound.c +++ b/src/libs/decoders/SDL_sound.c @@ -145,7 +145,10 @@ int Sound_Quit(void) BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0); while (((volatile Sound_Sample *) sample_list) != NULL) - Sound_FreeSample(sample_list); + { + Sound_Sample *sample = sample_list; + Sound_FreeSample(sample); /* Updates sample_list. */ + } initialized = 0;