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.
This commit is contained in:
Sebastian Krzyszkowiak 2021-08-10 13:08:27 +02:00 committed by Sam Lantinga
parent de6ba40d9e
commit b3a989d0df
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}