From a581346fae3b086f48e51dadeb23e1a3f071475b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 4 Apr 2016 22:49:13 -0400 Subject: [PATCH] alsa: Make device enumeration robust against weird results with NULL strings. --- src/audio/alsa/SDL_alsa_audio.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index d0735957e..162ce8c6e 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -668,12 +668,17 @@ ALSA_Deinitialize(void) static void add_device(const int iscapture, const char *name, const char *_desc) { - char *desc = SDL_strdup(_desc); + char *desc = NULL; char *handle = NULL; - char *ptr; + char *ptr = NULL; + if (!name || !_desc) { + return; /* nothing we can do with this...? */ + } + + desc = SDL_strdup(_desc); if (!desc) { - return; + return; /* oh well, out of memory. Skip it. */ } /* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output" */