Commit c638b4a682a14a1d2dd8d287ab1e239635f3a143

Sylvain 2023-01-16T09:21:24

SDL_CreateAudioStream: check for invalid parameters

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index be9e9cb..7a9dc91 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -1011,6 +1011,16 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format,
     Uint8 pre_resample_channels;
     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));
     if (retval == NULL) {
         SDL_OutOfMemory();