From c8061ed2d1ca42b703deaca22003bbdeb18f09ed Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Sat, 13 Nov 2021 10:33:37 -0600
Subject: [PATCH] alsa: Fix possible uninitialized string
---
src/audio/alsa/SDL_alsa_audio.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index d6f2a1050d..79c879fb63 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -656,10 +656,11 @@ ALSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
#ifdef SND_CHMAP_API_VERSION
chmap = ALSA_snd_pcm_get_chmap(pcm_handle);
if (chmap) {
- ALSA_snd_pcm_chmap_print(chmap, sizeof(chmap_str), chmap_str);
- if (SDL_strcmp("FL FR FC LFE RL RR", chmap_str) == 0 ||
- SDL_strcmp("FL FR FC LFE SL SR", chmap_str) == 0) {
- this->hidden->swizzle_func = no_swizzle;
+ if (ALSA_snd_pcm_chmap_print(chmap, sizeof(chmap_str), chmap_str) > 0) {
+ if (SDL_strcmp("FL FR FC LFE RL RR", chmap_str) == 0 ||
+ SDL_strcmp("FL FR FC LFE SL SR", chmap_str) == 0) {
+ this->hidden->swizzle_func = no_swizzle;
+ }
}
free(chmap);
}