Better safety checks for Cocoa menu code, potential crash fix. b=532585 r=josh

This commit is contained in:
Benjamin Frisch 2009-12-29 14:51:49 -05:00
parent 742c8af65f
commit 8bf2995eda

View File

@ -866,13 +866,11 @@ static pascal OSStatus MyMenuEventHandler(EventHandlerCallRef myHandler, EventRe
// don't request a menu item that doesn't exist or we crash
// this might happen just due to some random quirks in the event system
PRUint32 itemCount;
targetMenu->GetVisibleItemCount(itemCount);
if (aPos >= itemCount)
nsMenuObjectX* target = targetMenu->GetVisibleItemAt((PRUint32)aPos);
if (!target)
return eventNotHandledErr;
// Send DOM event if we're over a menu item
nsMenuObjectX* target = targetMenu->GetVisibleItemAt((PRUint32)aPos);
if (target->MenuObjectType() == eMenuItemObjectType) {
nsMenuItemX* targetMenuItem = static_cast<nsMenuItemX*>(target);
PRBool handlerCalledPreventDefault; // but we don't actually care