kmsdrm: slightly better device index hint parsing.

main
Ryan C. Gordon 2022-07-27 12:12:03 -04:00
parent 02c8747176
commit 42165fe8d1
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 3 additions and 2 deletions

View File

@ -81,8 +81,9 @@ get_driindex(void)
hint = SDL_GetHint(SDL_HINT_KMSDRM_DEVICE_INDEX);
if (hint && *hint) {
const int idx = SDL_atoi(hint);
if (idx >= 0) {
char *endptr = NULL;
const int idx = (int) SDL_strtol(hint, &endptr, 10);
if ((*endptr == '\0') && (idx >= 0)) { /* *endptr==0 means "whole string was a valid number" */
return idx; /* we'll take the user's request here. */
}
}