mirror of
https://github.com/yawut/SDL.git
synced 2026-09-08 09:06:29 -05:00
Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
This commit is contained in:
@@ -968,6 +968,12 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||
* !!! FIXME: good in practice as it sounds in theory, though.
|
||||
*/
|
||||
|
||||
/* Sanity check target pointer */
|
||||
if (cvt == NULL) {
|
||||
SDL_InvalidParamError("cvt");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* there are no unsigned types over 16 bits, so catch this up front. */
|
||||
if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
|
||||
SDL_SetError("Invalid source format");
|
||||
@@ -979,6 +985,10 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||
}
|
||||
|
||||
/* prevent possible divisions by zero, etc. */
|
||||
if ((src_channels == 0) || (dst_channels == 0)) {
|
||||
SDL_SetError("Source or destination channels is zero");
|
||||
return -1;
|
||||
}
|
||||
if ((src_rate == 0) || (dst_rate == 0)) {
|
||||
SDL_SetError("Source or destination rate is zero");
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user