Skip to content

Commit 25f9ed8

Browse files
dos1slouken
authored andcommitted
audio: Fix false positives in driver name comparison
Without this change, driver names don't get matched correctly; for example "a" can get matched with "alsa" since it only checks whether the string matches up to the length of the requested driver name.
1 parent b3a989d commit 25f9ed8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/audio/SDL_audio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,8 @@ SDL_AudioInit(const char *driver_name)
980980
: SDL_strlen(driver_attempt);
981981

982982
for (i = 0; bootstrap[i]; ++i) {
983-
if (SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0) {
983+
if ((driver_attempt_len == SDL_strlen(bootstrap[i]->name)) &&
984+
(SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0)) {
984985
tried_to_init = 1;
985986
SDL_zero(current_audio);
986987
current_audio.name = bootstrap[i]->name;

0 commit comments

Comments
 (0)