Bläddra i källkod

Fix invalid WideCharToMultiByte parameters, caused by 1fd19b5d and probably causing an error on Windows 2016 at least.

Win32 docs for the two params: "For the CP_UTF7 and CP_UTF8 settings for CodePage, this parameter must be set to NULL. Otherwise, the function fails with ERROR_INVALID_PARAMETER."
Martijn Laan 4 månader sedan
förälder
incheckning
d8a1a8f751

+ 3 - 1
Components/Lzma2/Util/7z/7zMain.c

@@ -194,8 +194,10 @@ static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s
       {
         const char defaultChar = '_';
         BOOL defUsed;
+        const char *pDefaultChar = (codePage == CP_UTF7 || codePage == CP_UTF8) ? NULL : &defaultChar;
+        BOOL *pDefUsed = pDefaultChar ? NULL : &defUsed;
         const unsigned numChars = (unsigned)WideCharToMultiByte(
-            codePage, 0, (LPCWSTR)s, (int)len, (char *)buf->data, (int)size, &defaultChar, &defUsed);
+            codePage, 0, (LPCWSTR)s, (int)len, (char *)buf->data, (int)size, pDefaultChar, pDefUsed);
         if (numChars == 0 || numChars >= size)
           return SZ_ERROR_FAIL;
         buf->data[numChars] = 0;

BIN
Projects/Src/Compression.SevenZipDecoder/7zDecode/IS7zDec.obj