[PATCH] shlwapi: Fix the length returned by SHFormatDateTimeA().

Francois Gouget fgouget at codeweavers.com
Tue Aug 31 07:57:44 CDT 2021


The ANSI string may be longer than the Unicode one.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
This fixes the ja_JP and zh_CN tests.
https://test.winehq.org/data/patterns.html#shlwapi:ordinal

Hindi still fails because it is a Unicode-only locale so all the 
underlying kernel32 ANSI functions fail (bug 51407).
---
 dlls/shlwapi/ordinal.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c
index 52cc3b725fa..a45d75254a9 100644
--- a/dlls/shlwapi/ordinal.c
+++ b/dlls/shlwapi/ordinal.c
@@ -4360,7 +4360,8 @@ INT WINAPI SHFormatDateTimeA(const FILETIME UNALIGNED *fileTime, DWORD *flags,
     retval = SHFormatDateTimeW(fileTime, flags, bufW, size);
 
     if (retval != 0)
-        WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, size, NULL, NULL);
+        /* the ANSI length may differ from the Unicode one */
+        retval = WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, size, NULL, NULL);
 
     HeapFree(GetProcessHeap(), 0, bufW);
     return retval;
-- 
2.30.2




More information about the wine-devel mailing list