Skip to content

Commit

Permalink
Fixed bug 4525 - Fix crash in ALSA_HotplugThread caused by bad return…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
slouken committed Mar 17, 2019
1 parent 55f18d3 commit 3525534
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/audio/alsa/SDL_alsa_audio.c
Expand Up @@ -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;
Expand Down

0 comments on commit 3525534

Please sign in to comment.