Commit 06a6b189 authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

user32: Cope with null LPMENUITEMINFO in SetMenuItemInfo.

parent 2ff6bd27
......@@ -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;
}
......
......@@ -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);
......
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