Fixed bug 4525 - Fix crash in ALSA_HotplugThread caused by bad return value check
authorSam Lantinga
Sat, 16 Mar 2019 18:48:21 -0700
changeset 12648a4824cbecd16
parent 12647 fa75f0fb9e96
child 12649 3d2042ac4ab9
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
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Sat Mar 16 18:45:10 2019 -0700
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Sat Mar 16 18:48:21 2019 -0700
     1.3 @@ -788,7 +788,7 @@
     1.4          ALSA_Device *seen;
     1.5          ALSA_Device *prev;
     1.6  
     1.7 -        if (ALSA_snd_device_name_hint(-1, "pcm", &hints) != -1) {
     1.8 +        if (ALSA_snd_device_name_hint(-1, "pcm", &hints) == 0) {
     1.9              int i, j;
    1.10              const char *match = NULL;
    1.11              int bestmatch = 0xFFFF;