Commit 7cd2821d authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Don't validate calendar id for GetCalendarInfo(CAL_ITWODIGITYEARMAX).

parent f2d98ea7
......@@ -681,7 +681,7 @@ static void test_GetCalendarInfo(void)
char bufferA[20];
WCHAR bufferW[20];
DWORD val1, val2;
int ret, ret2;
int i, j, ret, ret2;
if (!pGetCalendarInfoA || !pGetCalendarInfoW)
{
......@@ -744,6 +744,22 @@ static void test_GetCalendarInfo(void)
ok( ret2, "GetCalendarInfoW failed err %lu\n", GetLastError() );
ret2 = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
ok( ret == ret2, "got %d, expected %d\n", ret, ret2 );
for (i = CAL_GREGORIAN; i <= CAL_UMALQURA; i++)
{
WCHAR name[80];
ret = pGetCalendarInfoW( 0x0409, i, CAL_SCALNAME, name, ARRAY_SIZE(name), NULL);
for (j = CAL_ICALINTVALUE; j <= CAL_SRELATIVELONGDATE; j++)
{
ret2 = pGetCalendarInfoW( 0x0409, i, j, bufferW, ARRAY_SIZE(bufferW), NULL);
if (ret || j == CAL_ITWODIGITYEARMAX)
ok( ret2 || broken(j == CAL_SRELATIVELONGDATE), /* win7 doesn't have this */
"calendar %u %s value %02x failed\n", i, wine_dbgstr_w(name), j );
else
ok( !ret2, "calendar %u %s value %02x succeeded %s\n",
i, wine_dbgstr_w(name), j, wine_dbgstr_w(bufferW) );
}
}
}
static void test_GetDynamicTimeZoneInformation(void)
......
......@@ -552,8 +552,8 @@ static const NLS_LOCALE_DATA *get_locale_data( UINT idx )
static const struct calendar *get_calendar_data( const NLS_LOCALE_DATA *locale, UINT id )
{
if (id == CAL_HIJRI) id = locale->islamic_cal[0];
else if (id == CAL_PERSIAN) id = locale->islamic_cal[1];
if (id == CAL_HIJRI && locale->islamic_cal[0]) id = locale->islamic_cal[0];
else if (id == CAL_PERSIAN && locale->islamic_cal[1]) id = locale->islamic_cal[1];
if (!id || id > locale_table->nb_calendars) return NULL;
return (const struct calendar *)((const char *)locale_table + locale_table->calendars_offset +
......@@ -1617,7 +1617,7 @@ static int get_calendar_info( const NLS_LOCALE_DATA *locale, CALID id, CALTYPE t
}
else if (len < 0 || value) goto invalid;
if (id != CAL_GREGORIAN)
if (id != CAL_GREGORIAN && type != CAL_ITWODIGITYEARMAX)
{
const USHORT *ids = locale_strings + locale->scalendartype;
for (i = 0; i < ids[0]; i++) if (ids[1 + i] == id) break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment