From 342ec5113171214154cb197bb3e0e3a0056ea2ad Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 10 Aug 2023 23:43:58 +0200 Subject: [PATCH] Fix overflow when doing SDL_sscanf("%hd", ...) An overflow occured in the stdlib_sscanf test, when using msys2 clang32 toolchain. --- src/stdlib/SDL_string.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index edbffcde3..ca6600137 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -1275,7 +1275,9 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) suppress = SDL_TRUE; break; case 'h': - if (inttype > DO_SHORT) { + if (inttype == DO_INT) { + inttype = DO_SHORT; + } else if (inttype > DO_SHORT) { ++inttype; } break;