Skip to content

Commit

Permalink
mixer.c: Fixed Clang's Code model warning
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Wohlstand committed Aug 3, 2024
1 parent 0f0c3a1 commit ad845a7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit ad845a7

Please sign in to comment.