Bug 1276901 - prevent null pointer dereference on |nativeKeyEvent|. r?janv
MozReview-Commit-ID: J3GtMQDU1Yq
--- a/layout/xul/nsMenuBarListener.cpp
+++ b/layout/xul/nsMenuBarListener.cpp
@@ -206,17 +206,18 @@ nsMenuBarListener::KeyPress(nsIDOMEvent*
InitAccessKey();
if (mAccessKey)
{
// If accesskey handling was forwarded to a child process, wait for
// the mozaccesskeynotfound event before handling accesskeys.
WidgetKeyboardEvent* nativeKeyEvent =
aKeyEvent->WidgetEventPtr()->AsKeyboardEvent();
- if (nativeKeyEvent && nativeKeyEvent->mAccessKeyForwardedToChild) {
+ if (!nativeKeyEvent || nativeKeyEvent &&
+ nativeKeyEvent->mAccessKeyForwardedToChild) {
return NS_OK;
}
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
uint32_t keyCode, charCode;
keyEvent->GetKeyCode(&keyCode);
keyEvent->GetCharCode(&charCode);
@@ -246,17 +247,17 @@ nsMenuBarListener::KeyPress(nsIDOMEvent*
// The opened menu will listen next keyup event.
// Therefore, we should clear the keydown flags here.
mAccessKeyDown = mAccessKeyDownCanceled = false;
aKeyEvent->StopPropagation();
aKeyEvent->PreventDefault();
}
- }
+ }
#ifndef XP_MACOSX
// Also need to handle F10 specially on Non-Mac platform.
else if (nativeKeyEvent->mMessage == eKeyPress && keyCode == NS_VK_F10) {
if ((GetModifiersForAccessKey(keyEvent) & ~MODIFIER_CONTROL) == 0) {
// The F10 key just went down by itself or with ctrl pressed.
// In Windows, both of these activate the menu bar.
mMenuBarFrame->SetActiveByKeyboard();
ToggleMenuActiveState();