mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-04 18:57:38 +00:00
kernelbase: Check if locale is NULL before using it in Internal_EnumDateFormats().
Initialize the calendars variable after checking if locale is NULL before using it to avoid NULL pointer references. Fix a Excel 2016 crash when formatting dates with the custom format 'ddd'. It calls EnumDateFormatsExEx() with the 'yi-Hebr' locale, which is added in Win10. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55099
This commit is contained in:
parent
d8cd320db6
commit
884cff8214
|
@ -8402,6 +8402,36 @@ static void dump_sortkeys( char *argv[] )
|
|||
fclose( f );
|
||||
}
|
||||
|
||||
static BOOL CALLBACK EnumDateFormatsExEx_proc(LPWSTR date_format_string, CALID calendar_id, LPARAM lp)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void test_EnumDateFormatsExEx(void)
|
||||
{
|
||||
DWORD error;
|
||||
BOOL ret;
|
||||
|
||||
/* Invalid locale name */
|
||||
ret = EnumDateFormatsExEx(EnumDateFormatsExEx_proc, L"deadbeef", DATE_SHORTDATE, 0);
|
||||
error = GetLastError();
|
||||
ok(!ret, "EnumDateFormatsExEx succeeded.\n");
|
||||
ok(error == ERROR_INVALID_PARAMETER, "Got unexpected error %#lx.\n", error);
|
||||
|
||||
/* yi-Hebr is missing on versions < Win10 */
|
||||
/* Running the following tests will cause other tests that use LOCALE_CUSTOM_UNSPECIFIED to
|
||||
* report yi-Hebr instead the default locale on Windows 10. So run them at the end */
|
||||
ret = EnumDateFormatsExEx(EnumDateFormatsExEx_proc, L"yi-Hebr", DATE_SHORTDATE, 0);
|
||||
error = GetLastError();
|
||||
ok(ret || (!ret && error == ERROR_INVALID_PARAMETER), /* < Win10 */
|
||||
"EnumDateFormatsExEx failed, error %#lx.\n", error);
|
||||
|
||||
ret = EnumDateFormatsExEx(EnumDateFormatsExEx_proc, L"yi-Hebr", DATE_LONGDATE, 0);
|
||||
error = GetLastError();
|
||||
ok(ret || (!ret && error == ERROR_INVALID_PARAMETER), /* < Win10 */
|
||||
"EnumDateFormatsExEx failed, error %#lx.\n", error);
|
||||
}
|
||||
|
||||
START_TEST(locale)
|
||||
{
|
||||
char **argv;
|
||||
|
@ -8473,4 +8503,7 @@ START_TEST(locale)
|
|||
test_EnumCalendarInfoW();
|
||||
test_EnumCalendarInfoExA();
|
||||
test_EnumCalendarInfoExW();
|
||||
|
||||
/* Run this test at the end */
|
||||
test_EnumDateFormatsExEx();
|
||||
}
|
||||
|
|
|
@ -4390,7 +4390,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumDateFormats( DATEFMT_ENUMPROCW proc,
|
|||
INT i, j, ret;
|
||||
DWORD pos;
|
||||
const struct calendar *cal;
|
||||
const USHORT *calendars = locale_strings + locale->scalendartype;
|
||||
const USHORT *calendars;
|
||||
const DWORD *array;
|
||||
|
||||
if (!proc || !locale)
|
||||
|
@ -4399,6 +4399,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumDateFormats( DATEFMT_ENUMPROCW proc,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
calendars = locale_strings + locale->scalendartype;
|
||||
|
||||
switch (flags & ~LOCALE_USE_CP_ACP)
|
||||
{
|
||||
case 0:
|
||||
|
|
Loading…
Reference in a new issue