From 42165fe8d1423c4fa3232ce6952459653f69a3e5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 27 Jul 2022 12:12:03 -0400 Subject: [PATCH] kmsdrm: slightly better device index hint parsing. --- src/video/kmsdrm/SDL_kmsdrmvideo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 92ecc2d90..def72334b 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -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. */ } }