Commit 4a0b9522b6206a36411ea12024695c159aceb34f

Ryan C. Gordon 2023-05-17T20:06:58

audio: Load .WAV files with format->blockalign==0. In theory this is illegal, but legit wavefiles in the field do it, and it's easy to bump it to 1 for general purposes. Formats with more specific alignment requirements already check for them separately. Fixes #7714. (cherry picked from commit 2e646c7141b3009628abda2a964ba5f9d1702e1a)

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index bafbd88..6959c56 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -1711,7 +1711,7 @@ static int WaveCheckFormat(WaveFile *file, size_t datalength)
 
         /* All supported formats must have a proper block size. */
         if (format->blockalign == 0) {
-            return SDL_SetError("Invalid block alignment");
+            format->blockalign = 1;  /* force it to 1 if it was unset. */
         }
 
         /* If the fact chunk is valid and the appropriate hint is set, the