SDL: Fix null pointer dereference in SDL_BindAudioStreams()

From 751917cb6fed313820185d0f1c4c0ec68331b774 Mon Sep 17 00:00:00 2001
From: Mathieu Eyraud <[EMAIL REDACTED]>
Date: Tue, 20 Feb 2024 19:31:27 +0100
Subject: [PATCH] Fix null pointer dereference in SDL_BindAudioStreams()

---
 src/audio/SDL_audio.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index ab0872b16ec2..453d73702ba3 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1792,15 +1792,11 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int
 
             if (retval != 0) {
                 int j;
-                for (j = 0; j <= i; j++) {
-#ifdef _MSC_VER /* Visual Studio analyzer can't tell that we've already verified streams[j] isn't NULL */
-#pragma warning(push)
-#pragma warning(disable : 28182)
-#endif
+                for (j = 0; j < i; j++) {
                     SDL_UnlockMutex(streams[j]->lock);
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
+                }
+                if (streams[i]) {
+                    SDL_UnlockMutex(streams[i]->lock);
                 }
                 break;
             }