diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index faec19c9f..49abe1d9c 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -718,9 +718,15 @@ SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format /* !!! FIXME: remove this if we can get the resampler to work in-place again. */ float *dst = (float *) (cvt->buf + srclen); const int dstlen = (cvt->len * cvt->len_mult) - srclen; - const int paddingsamples = (ResamplerPadding(inrate, outrate) * chans); + const int requestedpadding = ResamplerPadding(inrate, outrate); + int paddingsamples; float *padding; + if (requestedpadding < INT32_MAX / chans) { + paddingsamples = requestedpadding * chans; + } else { + paddingsamples = 0; + } SDL_assert(format == AUDIO_F32SYS); /* we keep no streaming state here, so pad with silence on both ends. */ @@ -889,10 +895,14 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, return SDL_SetError("Invalid source channels"); } else if (!SDL_SupportedChannelCount(dst_channels)) { return SDL_SetError("Invalid destination channels"); - } else if (src_rate == 0) { - return SDL_SetError("Source rate is zero"); - } else if (dst_rate == 0) { - return SDL_SetError("Destination rate is zero"); + } else if (src_rate <= 0) { + return SDL_SetError("Source rate is equal to or less than zero"); + } else if (dst_rate <= 0) { + return SDL_SetError("Destination rate is equal to or less than zero"); + } else if (src_rate >= INT32_MAX / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) { + return SDL_SetError("Source rate is too high"); + } else if (dst_rate >= INT32_MAX / RESAMPLER_SAMPLES_PER_ZERO_CROSSING) { + return SDL_SetError("Destination rate is too high"); } #if DEBUG_CONVERT