Bug 1278452 - Fix some null checks in dom/xbl/. r=mrbkap.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 07 Jun 2016 15:24:48 +1000
changeset 301029 9b6d23819097bb067fd9bea9b9d45df0f7fdc062
parent 301028 ac0df3cacb3bf8356a9c9ca15c803b512b7de12e
child 301030 45ea273f14d1f1e17c352d7a5df4f1deff43283e
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1278452
milestone50.0a1
Bug 1278452 - Fix some null checks in dom/xbl/. r=mrbkap.
dom/xbl/nsXBLService.cpp
--- a/dom/xbl/nsXBLService.cpp
+++ b/dom/xbl/nsXBLService.cpp
@@ -536,19 +536,21 @@ nsXBLService::AttachGlobalKeyHandler(Eve
   nsCOMPtr<nsIContent> contentNode(do_QueryInterface(aTarget));
   if (contentNode) {
     // Only attach if we're really in a document
     nsCOMPtr<nsIDocument> doc = contentNode->GetUncomposedDoc();
     if (doc)
       piTarget = doc; // We're a XUL keyset. Attach to our document.
   }
 
-  EventListenerManager* manager = piTarget->GetOrCreateListenerManager();
+  if (!piTarget)
+    return NS_ERROR_FAILURE;
 
-  if (!piTarget || !manager)
+  EventListenerManager* manager = piTarget->GetOrCreateListenerManager();
+  if (!manager)
     return NS_ERROR_FAILURE;
 
   // the listener already exists, so skip this
   if (contentNode && contentNode->GetProperty(nsGkAtoms::listener))
     return NS_OK;
 
   nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(contentNode));
 
@@ -581,19 +583,21 @@ nsXBLService::DetachGlobalKeyHandler(Eve
   if (!contentNode) // detaching is only supported for content nodes
     return NS_ERROR_FAILURE;
 
   // Only attach if we're really in a document
   nsCOMPtr<nsIDocument> doc = contentNode->GetUncomposedDoc();
   if (doc)
     piTarget = do_QueryInterface(doc);
 
-  EventListenerManager* manager = piTarget->GetOrCreateListenerManager();
+  if (!piTarget)
+    return NS_ERROR_FAILURE;
 
-  if (!piTarget || !manager)
+  EventListenerManager* manager = piTarget->GetOrCreateListenerManager();
+  if (!manager)
     return NS_ERROR_FAILURE;
 
   nsIDOMEventListener* handler =
     static_cast<nsIDOMEventListener*>(contentNode->GetProperty(nsGkAtoms::listener));
   if (!handler)
     return NS_ERROR_FAILURE;
 
   static_cast<nsXBLWindowKeyHandler*>(handler)->