SDL: audio: Fix potential NULL dereference in AudioStream gain adjustment.

From ccd5fcef12cd259f93155d143ad92e008c869e02 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 28 Jan 2025 13:14:25 -0500
Subject: [PATCH] audio: Fix potential NULL dereference in AudioStream gain
 adjustment.

You can end up with a NULL scratch buffer, which is otherwise not needed on
this path, then ConvertAudio will end up needing that scratch space to move
to float32 to apply gain.

Fixes #12091.
(I assume.)
---
 src/audio/SDL_audiocvt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index b247b4c58fb86..f751b0e580bdb 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -1022,7 +1022,7 @@ static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int o
         Uint8* work_buffer = NULL;
 
         // Ensure we have enough scratch space for any conversions
-        if ((src_format != dst_format) || (src_channels != dst_channels)) {
+        if ((src_format != dst_format) || (src_channels != dst_channels) || (gain != 1.0f)) {
             work_buffer = EnsureAudioStreamWorkBufferSize(stream, output_frames * max_frame_size);
 
             if (!work_buffer) {