[PATCH 0/1] MR3190: 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'. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3190
From: Zhiyi Zhang <zzhang(a)codeweavers.com> 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'. --- dlls/kernelbase/locale.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 45180f4bb8a..e8060fe9205 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -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: -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3190
Could you add a test for how this is called by Excel? Specifically, is it called with actually invalid locale, or is it a valid one that we don't recognize. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3190#note_37311
participants (3)
-
Nikolay Sivov (@nsivov) -
Zhiyi Zhang -
Zhiyi Zhang (@zhiyi)