From e559b271b560e42a8c7eee3ae81a5030e7f5ed67 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 5 Jul 2024 12:44:25 -0700 Subject: [PATCH] Clear the wave format so the channel map is cleared before returning from SDL_LoadWAV_IO() --- src/audio/SDL_wave.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 9b1c43d964..a7e6b48d4d 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -2080,6 +2080,16 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uin int result = -1; WaveFile file; + if (spec) { + SDL_zerop(spec); + } + if (audio_buf) { + *audio_buf = NULL; + } + if (audio_len) { + *audio_len = 0; + } + /* Make sure we are passed a valid data source */ if (!src) { goto done; /* Error may come from SDL_IOStream. */ @@ -2094,9 +2104,6 @@ int SDL_LoadWAV_IO(SDL_IOStream *src, SDL_bool closeio, SDL_AudioSpec *spec, Uin goto done; } - *audio_buf = NULL; - *audio_len = 0; - SDL_zero(file); file.riffhint = WaveGetRiffSizeHint(); file.trunchint = WaveGetTruncationHint();