Bug 1276901 - prevent null pointer dereference on |nativeKeyEvent|. r?janv draft
authorAndi-Bogdan Postelnicu <bogdan.postelnicu@softvision.ro>
Tue, 31 May 2016 15:41:12 +0300
changeset 373216 bf99fc22a8d7a0cf3d9bc43f436c4ae28f9076e8
parent 372838 cad514ad49c199e823a92e8c8d27e16c22c3cac7
child 522353 6d5df250b6375086214d3b24159659706f3fcc5f
push id19709
push userBogdan.Postelnicu@softvision.ro
push dateTue, 31 May 2016 12:50:15 +0000
reviewersjanv
bugs1276901
milestone49.0a1
Bug 1276901 - prevent null pointer dereference on |nativeKeyEvent|. r?janv MozReview-Commit-ID: J3GtMQDU1Yq
layout/xul/nsMenuBarListener.cpp
--- 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();