Browse Source

Don't pass NULL to strncmp

Mathieu Eyraud 1 year ago
parent
commit
2b0c0f5b6b
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/audio/alsa/SDL_alsa_audio.c

+ 1 - 1
src/audio/alsa/SDL_alsa_audio.c

@@ -812,7 +812,7 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_output, SDL_bool *has_de
 
                 // only want physical hardware interfaces
                 const SDL_bool is_default = (has_default == i) ? SDL_TRUE : SDL_FALSE;
-                if (is_default || SDL_strncmp(name, match, match_len) == 0) {
+                if (is_default || (match != NULL && SDL_strncmp(name, match, match_len) == 0)) {
                     char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID");
                     const SDL_bool isoutput = (ioid == NULL) || (SDL_strcmp(ioid, "Output") == 0);
                     const SDL_bool isinput = (ioid == NULL) || (SDL_strcmp(ioid, "Input") == 0);