Fix FormatMessageW in PAL
authorJan Vorlicek <janvorli@microsoft.com>
Wed, 1 Apr 2015 23:31:53 +0000 (01:31 +0200)
committerJan Vorlicek <janvorli@microsoft.com>
Wed, 1 Apr 2015 23:48:56 +0000 (01:48 +0200)
The function was not properly accessing the Arguments list when the
FORMAT_MESSAGE_ARGUMENT_ARRAY flag was set. The va_list on Linux is
a struct with four members, so indexing Arguments array without
casting it first to a WCHAR** gets completely wrong results.

src/pal/src/misc/fmtmessage.cpp

index 8003b7c..53dcd67 100644 (file)
@@ -711,7 +711,7 @@ FormatMessageW(
 
                     if ( !bIsVaList )
                     {
-                        lpInsertString = (LPWSTR)Arguments[ Index - 1 ];
+                        lpInsertString = ((LPWSTR*)Arguments)[ Index - 1 ];
                     }
                     else
                     {
@@ -791,7 +791,7 @@ FormatMessageW(
 
                     if ( !bIsVaList )
                     {
-                         lpInsert = (LPWSTR)Arguments[ Index - 1 ];
+                        lpInsert = ((LPWSTR*)Arguments)[Index - 1];
                     }
                     else
                     {