user32: Insert menu item only after contents of the passed in menu item info have been verified.

This commit is contained in:
Dmitry Timoshkov 2007-06-17 21:45:55 +09:00 committed by Alexandre Julliard
parent 1dbe178f5e
commit 79de98f982

View file

@ -4639,6 +4639,9 @@ BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos,
const MENUITEMINFOA *lpmii)
{
MENUITEMINFOA mii;
TRACE("hmenu %p, item %u, by pos %d, info %p\n", hmenu, item, bypos, lpmii);
if( lpmii->cbSize != sizeof( mii) &&
lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem)) {
SetLastError( ERROR_INVALID_PARAMETER);
@ -4660,6 +4663,9 @@ BOOL WINAPI SetMenuItemInfoW(HMENU hmenu, UINT item, BOOL bypos,
const MENUITEMINFOW *lpmii)
{
MENUITEMINFOW mii;
TRACE("hmenu %p, item %u, by pos %d, info %p\n", hmenu, item, bypos, lpmii);
if( lpmii->cbSize != sizeof( mii) &&
lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem)) {
SetLastError( ERROR_INVALID_PARAMETER);
@ -4771,8 +4777,11 @@ UINT WINAPI GetMenuDefaultItem(HMENU hmenu, UINT bypos, UINT flags)
BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
const MENUITEMINFOA *lpmii)
{
MENUITEM *item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
MENUITEM *item;
MENUITEMINFOA mii;
TRACE("hmenu %p, item %04x, by pos %d, info %p\n", hMenu, uItem, bypos, lpmii);
if( lpmii->cbSize != sizeof( mii) &&
lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem)) {
SetLastError( ERROR_INVALID_PARAMETER);
@ -4783,6 +4792,8 @@ BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
mii.cbSize = sizeof( mii);
mii.hbmpItem = NULL;
}
item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
return SetMenuItemInfo_common(item, (const MENUITEMINFOW *)&mii, FALSE);
}
@ -4793,8 +4804,11 @@ BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL bypos,
const MENUITEMINFOW *lpmii)
{
MENUITEM *item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
MENUITEM *item;
MENUITEMINFOW mii;
TRACE("hmenu %p, item %04x, by pos %d, info %p\n", hMenu, uItem, bypos, lpmii);
if( lpmii->cbSize != sizeof( mii) &&
lpmii->cbSize != sizeof( mii) - sizeof ( mii.hbmpItem)) {
SetLastError( ERROR_INVALID_PARAMETER);
@ -4805,6 +4819,8 @@ BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL bypos,
mii.cbSize = sizeof( mii);
mii.hbmpItem = NULL;
}
item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
return SetMenuItemInfo_common(item, &mii, TRUE);
}