From 35255342cdca52ba45466364eefeb04c62d00873 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 16 Mar 2019 18:48:21 -0700 Subject: [PATCH] Fixed bug 4525 - Fix crash in ALSA_HotplugThread caused by bad return value check Anthony Pesch Fix snd_device_name_hint return value check According to the ALSA documentation, snd_device_name_hint returns 0 on success, otherwise a negative error code. The code previously only considered -1 to be an error, which let other error codes through resulting in a segfault when hints (which was NULL) was dereferenced --- src/audio/alsa/SDL_alsa_audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 58f30fc79..9364fc1b8 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -788,7 +788,7 @@ ALSA_HotplugThread(void *arg) ALSA_Device *seen; ALSA_Device *prev; - if (ALSA_snd_device_name_hint(-1, "pcm", &hints) != -1) { + if (ALSA_snd_device_name_hint(-1, "pcm", &hints) == 0) { int i, j; const char *match = NULL; int bestmatch = 0xFFFF;