Skip to content

Commit b3a989d

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

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/video/SDL_video.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ SDL_VideoInit(const char *driver_name)
505505
: SDL_strlen(driver_attempt);
506506

507507
for (i = 0; bootstrap[i]; ++i) {
508-
if (SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0) {
508+
if ((driver_attempt_len == SDL_strlen(bootstrap[i]->name)) &&
509+
(SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0)) {
509510
video = bootstrap[i]->create(index);
510511
break;
511512
}

0 commit comments

Comments
 (0)