Bruno Jesus : user32: Cope with null LPMENUITEMINFO in SetMenuItemInfo.
Alexandre Julliard
julliard at winehq.org
Mon Jan 27 13:32:53 CST 2014
Module: wine
Branch: master
Commit: 06a6b189f6c9712e64f3f7da908403f410295785
URL: http://source.winehq.org/git/wine.git/?a=commit;h=06a6b189f6c9712e64f3f7da908403f410295785
Author: Bruno Jesus <00cpxxx at gmail.com>
Date: Sat Jan 18 12:59:01 2014 -0200
user32: Cope with null LPMENUITEMINFO in SetMenuItemInfo.
---
dlls/user32/menu.c | 4 ++--
dlls/user32/tests/menu.c | 13 +++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 50545ee..bbaa5f3 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -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;
}
diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c
index 20126d4..d02eb91 100644
--- a/dlls/user32/tests/menu.c
+++ b/dlls/user32/tests/menu.c
@@ -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);
More information about the wine-cvs
mailing list