瀏覽代碼

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

An overflow occured in the stdlib_sscanf test, when using msys2 clang32 toolchain.

(cherry picked from commit 342ec5113171214154cb197bb3e0e3a0056ea2ad)
Anonymous Maarten 2 年之前
父節點
當前提交
10135b2d7b
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/stdlib/SDL_string.c

+ 3 - 1
src/stdlib/SDL_string.c

@@ -1190,7 +1190,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;