From b3a989d0dfeae6944f71459d31abf5e5cd89dc7e Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Tue, 10 Aug 2021 13:08:27 +0200 Subject: [PATCH] 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. --- src/video/SDL_video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index ba150905e..057dce09f 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -505,7 +505,8 @@ SDL_VideoInit(const char *driver_name) : SDL_strlen(driver_attempt); for (i = 0; bootstrap[i]; ++i) { - if (SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0) { + if ((driver_attempt_len == SDL_strlen(bootstrap[i]->name)) && + (SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0)) { video = bootstrap[i]->create(index); break; }