Deal with possible malloc(0) calls, as pointed out by static analysis.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 25 Jun 2018 12:55:23 -0400
changeset 12036e001d73657b3
parent 12035 1a7dec71e8e0
child 12037 5b86833971fb
Deal with possible malloc(0) calls, as pointed out by static analysis.
src/audio/SDL_audiocvt.c
     1.1 --- a/src/audio/SDL_audiocvt.c	Mon Jun 25 09:37:25 2018 -0700
     1.2 +++ b/src/audio/SDL_audiocvt.c	Mon Jun 25 12:55:23 2018 -0400
     1.3 @@ -724,7 +724,7 @@
     1.4      SDL_assert(format == AUDIO_F32SYS);
     1.5  
     1.6      /* we keep no streaming state here, so pad with silence on both ends. */
     1.7 -    padding = (float *) SDL_calloc(paddingsamples, sizeof (float));
     1.8 +    padding = (float *) SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof (float));
     1.9      if (!padding) {
    1.10          SDL_OutOfMemory();
    1.11          return;
    1.12 @@ -1291,7 +1291,7 @@
    1.13      retval->packetlen = packetlen;
    1.14      retval->rate_incr = ((double) dst_rate) / ((double) src_rate);
    1.15      retval->resampler_padding_samples = ResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels;
    1.16 -    retval->resampler_padding = (float *) SDL_calloc(retval->resampler_padding_samples, sizeof (float));
    1.17 +    retval->resampler_padding = (float *) SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof (float));
    1.18  
    1.19      if (retval->resampler_padding == NULL) {
    1.20          SDL_FreeAudioStream(retval);