Add additional input validation to SDL_BuildAudioCVT; add additional tests to automation (audio, rwops)
This commit is contained in:
parent
10fe9cd26f
commit
b507ef3afa
3 changed files with 483 additions and 12 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue