kernelbase: Fix infinite loop in Internal_EnumCalendarInfo.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52129
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jinoh Kang 2021-11-30 11:36:36 +09:00 committed by Alexandre Julliard
parent 4010876a42
commit 9c5fa40ebd
2 changed files with 6 additions and 31 deletions

View File

@ -7045,12 +7045,6 @@ static void test_EnumCalendarInfoA(void)
{ {
INT i; INT i;
if (!strcmp(winetest_platform, "wine"))
{
skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n");
return;
}
ok( EnumCalendarInfoA( calinfo_procA, ok( EnumCalendarInfoA( calinfo_procA,
LOCALE_USER_DEFAULT, LOCALE_USER_DEFAULT,
ENUM_ALL_CALENDARS, ENUM_ALL_CALENDARS,
@ -7079,12 +7073,6 @@ static void test_EnumCalendarInfoW(void)
{ {
INT i; INT i;
if (!strcmp(winetest_platform, "wine"))
{
skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n");
return;
}
ok( EnumCalendarInfoW( calinfo_procW, ok( EnumCalendarInfoW( calinfo_procW,
LOCALE_USER_DEFAULT, LOCALE_USER_DEFAULT,
ENUM_ALL_CALENDARS, ENUM_ALL_CALENDARS,
@ -7114,12 +7102,6 @@ static void test_EnumCalendarInfoExA(void)
{ {
INT i; INT i;
if (!strcmp(winetest_platform, "wine"))
{
skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n");
return;
}
ok( EnumCalendarInfoExA( calinfoex_procA, ok( EnumCalendarInfoExA( calinfoex_procA,
LOCALE_USER_DEFAULT, LOCALE_USER_DEFAULT,
ENUM_ALL_CALENDARS, ENUM_ALL_CALENDARS,
@ -7149,12 +7131,6 @@ static void test_EnumCalendarInfoExW(void)
{ {
INT i; INT i;
if (!strcmp(winetest_platform, "wine"))
{
skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n");
return;
}
ok( EnumCalendarInfoExW( calinfoex_procW, ok( EnumCalendarInfoExW( calinfoex_procW,
LOCALE_USER_DEFAULT, LOCALE_USER_DEFAULT,
ENUM_ALL_CALENDARS, ENUM_ALL_CALENDARS,

View File

@ -2727,8 +2727,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumCalendarInfo( CALINFO_ENUMPROCW proc,
BOOL exex, LPARAM lparam ) BOOL exex, LPARAM lparam )
{ {
WCHAR buffer[256]; WCHAR buffer[256];
DWORD optional = 0; CALID calendars[2] = { id };
INT ret; INT ret, i;
if (!proc) if (!proc)
{ {
@ -2739,13 +2739,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumCalendarInfo( CALINFO_ENUMPROCW proc,
if (id == ENUM_ALL_CALENDARS) if (id == ENUM_ALL_CALENDARS)
{ {
if (!GetLocaleInfoW( lcid, LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER, if (!GetLocaleInfoW( lcid, LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER,
(WCHAR *)&id, sizeof(id) / sizeof(WCHAR) )) return FALSE; (WCHAR *)&calendars[0], sizeof(calendars[0]) / sizeof(WCHAR) )) return FALSE;
if (!GetLocaleInfoW( lcid, LOCALE_IOPTIONALCALENDAR | LOCALE_RETURN_NUMBER, if (!GetLocaleInfoW( lcid, LOCALE_IOPTIONALCALENDAR | LOCALE_RETURN_NUMBER,
(WCHAR *)&optional, sizeof(optional) / sizeof(WCHAR) )) optional = 0; (WCHAR *)&calendars[1], sizeof(calendars[1]) / sizeof(WCHAR) )) calendars[1] = 0;
} }
for (;;) for (i = 0; i < ARRAY_SIZE(calendars) && calendars[i]; i++)
{ {
id = calendars[i];
if (type & CAL_RETURN_NUMBER) if (type & CAL_RETURN_NUMBER)
ret = GetCalendarInfoW( lcid, id, type, NULL, 0, (LPDWORD)buffer ); ret = GetCalendarInfoW( lcid, id, type, NULL, 0, (LPDWORD)buffer );
else if (unicode) else if (unicode)
@ -2764,8 +2765,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumCalendarInfo( CALINFO_ENUMPROCW proc,
else ret = proc( buffer ); else ret = proc( buffer );
} }
if (!ret) break; if (!ret) break;
if (!optional) break;
id = optional;
} }
return TRUE; return TRUE;
} }