Bug 1276901 - prevent null pointer dereference on |nativeKeyEvent|. r?dholbert draft
authorAndi-Bogdan Postelnicu <bogdan.postelnicu@softvision.ro>
Tue, 31 May 2016 15:41:12 +0300
changeset 432618 9846fb09f9dc82756821dbb6f2c84d5e63dcc5a2
parent 432230 3e73fd638e687a4d7f46613586e5156b8e2af846
child 535716 3d08cf893d9152d44bfd5ded83807ce61ea8091e
push id34382
push userbmo:bpostelnicu@mozilla.com
push dateWed, 02 Nov 2016 14:05:46 +0000
reviewersdholbert
bugs1276901
milestone52.0a1
Bug 1276901 - prevent null pointer dereference on |nativeKeyEvent|. r?dholbert 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);