SDL: audio: Fixed potential NULL dereference.

From 80b9986418907afdff942e1d18988269d606376b Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 13 Dec 2024 10:10:19 -0500
Subject: [PATCH] audio: Fixed potential NULL dereference.

This could happen if you call SDL_BindAudioStreams() when the subsystem isn't
initialized, and possibly in other corner cases.

Thanks to Qianxin CodeSafe Team, @QiAnXinCodeSafe, for discovering this issue!

Fixes #11643.
---
 src/audio/SDL_audio.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index a1108c34c1080..ada657be40472 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -234,6 +234,10 @@ static bool AudioDeviceCanUseSimpleCopy(SDL_AudioDevice *device)
 // should hold device->lock before calling.
 static void UpdateAudioStreamFormatsPhysical(SDL_AudioDevice *device)
 {
+    if (!device) {
+        return;
+    }
+
     if (device->recording) {  // for recording devices, we only want to move to float32 for postmix and gain, which we'll handle elsewhere.
         // we _do_ need to make sure the channel map is correct, though...
         for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) {