Browse Source

SDL_CreateAudioStream: check for invalid parameters

Sylvain 2 years ago
parent
commit
4156e6f52e
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/audio/SDL_audiocvt.c

+ 10 - 0
src/audio/SDL_audiocvt.c

@@ -1007,6 +1007,16 @@ SDL_CreateAudioStream(SDL_AudioFormat src_format,
     Uint8 pre_resample_channels;
     Uint8 pre_resample_channels;
     SDL_AudioStream *retval;
     SDL_AudioStream *retval;
 
 
+    if (src_channels == 0) {
+        SDL_InvalidParamError("src_channels");
+        return NULL;
+    }
+
+    if (dst_channels == 0) {
+        SDL_InvalidParamError("dst_channels");
+        return NULL;
+    }
+
     retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream));
     retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream));
     if (retval == NULL) {
     if (retval == NULL) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();