]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Stdio/vfwprintf.c
BaseTools/VfrCompile: Fix segmentation fault issues
[mirror_edk2.git] / StdLib / LibC / Stdio / vfwprintf.c
index 0554edb64516656572f2d811ddbdd54061280e49..f5cf3940f94044747f81404fff2ec5ceaf44d0ed 100644 (file)
@@ -1003,7 +1003,12 @@ reswitch: switch (ch) {
 \r
         mbs = initial;\r
         mbseqlen = wcrtomb(buf,\r
-            (wchar_t)GETARG(wint_t), &mbs);\r
+            /* The compiler "knows" that wint_t may be smaller than an int so\r
+               it warns about it when used as the type argument to va_arg().\r
+               Since any type of parameter smaller than an int is promoted to an int on a\r
+               function call, we must call GETARG with type int instead of wint_t.\r
+            */\r
+            (wchar_t)GETARG(int), &mbs);\r
         if (mbseqlen == (size_t)-1) {\r
           fp->_flags |= __SERR;\r
           goto error;\r
@@ -1015,7 +1020,7 @@ reswitch: switch (ch) {
       }\r
 #else\r
       if (flags & LONGINT)\r
-        *buf = (wchar_t)GETARG(wint_t);\r
+        *buf = (wchar_t)GETARG(int);\r
       else\r
         *buf = (wchar_t)btowc(GETARG(int));\r
       size = 1;\r
@@ -1915,7 +1920,7 @@ done:
       (*argtable) [n].pvoidarg = va_arg (ap, void *);\r
       break;\r
         case T_WINT:\r
-      (*argtable) [n].wintarg = va_arg (ap, wint_t);\r
+      (*argtable) [n].wintarg = va_arg (ap, int);\r
       break;\r
         case TP_WCHAR:\r
       (*argtable) [n].pwchararg = va_arg (ap, wchar_t *);\r