From ad845a7370cacac63920bc9a771031172eab6765 Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Sat, 3 Aug 2024 09:36:08 +0300 Subject: [PATCH] mixer.c: Fixed Clang's Code model warning Because it thinks that `num_channels` may have the value less than 1 (even there is no actual code that may assign it), it reports about the possible null pointer dereference at the `mix_channel` array pointer when `numchans` is zero. --- src/mixer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mixer.c b/src/mixer.c index 3b4d899..4d33f12 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -625,6 +625,9 @@ int MIXCALLCC Mix_AllocateChannels(int numchans) if (mix_channel_tmp || !numchans) { /* Apply the temporary pointer on success */ mix_channel = mix_channel_tmp; + if (num_channels < 0) { + num_channels = 0; + } if (numchans > num_channels) { /* Initialize the new channels */ for (i = num_channels; i < numchans; i++) {