Browse Source

Fix overflow when doing SDL_sscanf("%hd", ...)

An overflow occured in the stdlib_sscanf test, when using msys2 clang32 toolchain.
Anonymous Maarten 1 year ago
parent
commit
342ec51131
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/stdlib/SDL_string.c

+ 3 - 1
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;