user32: Cope with null LPMENUITEMINFO in SetMenuItemInfo.

This commit is contained in:
Bruno Jesus 2014-01-18 12:59:01 -02:00 committed by Alexandre Julliard
parent 2ff6bd271b
commit 06a6b189f6
2 changed files with 15 additions and 2 deletions

View File

@ -4795,8 +4795,8 @@ static BOOL MENU_NormalizeMenuItemInfoStruct( const MENUITEMINFOW *pmii_in,
MENUITEMINFOW *pmii_out )
{
/* do we recognize the size? */
if( pmii_in->cbSize != sizeof( MENUITEMINFOW) &&
pmii_in->cbSize != sizeof( MENUITEMINFOW) - sizeof( pmii_in->hbmpItem)) {
if( !pmii_in || (pmii_in->cbSize != sizeof( MENUITEMINFOW) &&
pmii_in->cbSize != sizeof( MENUITEMINFOW) - sizeof( pmii_in->hbmpItem)) ) {
SetLastError( ERROR_INVALID_PARAMETER);
return FALSE;
}

View File

@ -948,6 +948,19 @@ static void test_menu_add_string( void )
ok (!lstrcmpW( strbackW, expectedString ), "Menu text from Unicode version incorrect\n");
}
/* Just try some invalid parameter tests */
SetLastError(0xdeadbeef);
rc = SetMenuItemInfoA( hmenu, 0, TRUE, NULL );
ret = GetLastError();
ok (!rc, "SetMenuItemInfoA succeeded unexpectedly\n");
ok (ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
SetLastError(0xdeadbeef);
rc = SetMenuItemInfoA( hmenu, 0, FALSE, NULL );
ret = GetLastError();
ok (!rc, "SetMenuItemInfoA succeeded unexpectedly\n");
ok (ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
/* Just change ftype to string and see what text is stored */
memset(&info, 0x00, sizeof(info));
info.cbSize= sizeof(MENUITEMINFOA);