SDL: Fix #13276: Crash in SDL_GetAudioDeviceChannelMap (554be)

From 554bee6aae767ab96c5a7ae8d9ea71cb2c2d91e7 Mon Sep 17 00:00:00 2001
From: Paul Vick <[EMAIL REDACTED]>
Date: Tue, 24 Jun 2025 22:26:14 -0700
Subject: [PATCH] Fix #13276: Crash in SDL_GetAudioDeviceChannelMap

(cherry picked from commit de6a23028a2c7c05aa4f591969df1c9bb0f46003)
---
 src/audio/SDL_audio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 7420708abc65d..794d114b63233 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1575,7 +1575,9 @@ int *SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count)
     SDL_AudioDevice *device = ObtainPhysicalAudioDeviceDefaultAllowed(devid);
     if (device) {
         channels = device->spec.channels;
-        result = SDL_ChannelMapDup(device->chmap, channels);
+        if (channels > 0 && device->chmap) {
+            result = SDL_ChannelMapDup(device->chmap, channels);
+        }
     }
     ReleaseAudioDevice(device);