src/audio/SDL_audiocvt.c
changeset 12803 70d338e248c8
parent 12503 806492103856
child 12807 a39d8cdf50f4
     1.1 --- a/src/audio/SDL_audiocvt.c	Sat Jun 08 18:07:58 2019 -0700
     1.2 +++ b/src/audio/SDL_audiocvt.c	Sat Jun 08 18:22:18 2019 -0700
     1.3 @@ -718,9 +718,15 @@
     1.4      /* !!! FIXME: remove this if we can get the resampler to work in-place again. */
     1.5      float *dst = (float *) (cvt->buf + srclen);
     1.6      const int dstlen = (cvt->len * cvt->len_mult) - srclen;
     1.7 -    const int paddingsamples = (ResamplerPadding(inrate, outrate) * chans);
     1.8 +    const int requestedpadding = ResamplerPadding(inrate, outrate);
     1.9 +    int paddingsamples;
    1.10      float *padding;
    1.11  
    1.12 +    if (requestedpadding < INT32_MAX / chans) {
    1.13 +        paddingsamples = requestedpadding * chans;
    1.14 +    } else {
    1.15 +        paddingsamples = 0;
    1.16 +    }
    1.17      SDL_assert(format == AUDIO_F32SYS);
    1.18  
    1.19      /* we keep no streaming state here, so pad with silence on both ends. */
    1.20 @@ -889,10 +895,14 @@
    1.21          return SDL_SetError("Invalid source channels");
    1.22      } else if (!SDL_SupportedChannelCount(dst_channels)) {
    1.23          return SDL_SetError("Invalid destination channels");
    1.24 -    } else if (src_rate == 0) {
    1.25 -        return SDL_SetError("Source rate is zero");
    1.26 -    } else if (dst_rate == 0) {
    1.27 -        return SDL_SetError("Destination rate is zero");
    1.28 +    } else if (src_rate <= 0) {
    1.29 +        return SDL_SetError("Source rate is equal to or less than zero");
    1.30 +    } else if (dst_rate <= 0) {
    1.31 +        return SDL_SetError("Destination rate is equal to or less than zero");
    1.32 +    } else if (src_rate >= INT32_MAX / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) {
    1.33 +        return SDL_SetError("Source rate is too high");
    1.34 +    } else if (dst_rate >= INT32_MAX / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) {
    1.35 +        return SDL_SetError("Destination rate is too high");
    1.36      }
    1.37  
    1.38  #if DEBUG_CONVERT