Bug 1334080 - If a plugin is associated with a window that has no nsIWebNavigation, don't crash, r=qdot
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 10 Feb 2017 11:27:08 -0500
changeset 342316 6e553bdd65dc95d8605851dbb438a036a6e47c2b
parent 342315 da15441608ac1dccbb548fdc1fefb8c6a2a7f88a
child 342317 d0c41f50cedff98c68fa6ed29d6fc438364325ea
push id31349
push userphilringnalda@gmail.com
push dateSun, 12 Feb 2017 01:41:07 +0000
treeherdermozilla-central@43e17d5a1492 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1334080
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1334080 - If a plugin is associated with a window that has no nsIWebNavigation, don't crash, r=qdot MozReview-Commit-ID: CZLne2N498d
dom/plugins/base/nsPluginStreamListenerPeer.cpp
--- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp
+++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp
@@ -1286,29 +1286,38 @@ nsPluginStreamListenerPeer::VisitHeader(
 nsresult
 nsPluginStreamListenerPeer::GetInterfaceGlobal(const nsIID& aIID, void** result)
 {
   if (!mPluginInstance) {
     return NS_ERROR_FAILURE;
   }
 
   RefPtr<nsPluginInstanceOwner> owner = mPluginInstance->GetOwner();
-  if (owner) {
-    nsCOMPtr<nsIDocument> doc;
-    nsresult rv = owner->GetDocument(getter_AddRefs(doc));
-    if (NS_SUCCEEDED(rv) && doc) {
-      if  (nsPIDOMWindowOuter *window = doc->GetWindow()) {
-        nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(window);
-        nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(webNav);
-        return ir->GetInterface(aIID, result);
-      }
-    }
+  if (!owner) {
+    return NS_ERROR_FAILURE;
+  }
+
+  nsCOMPtr<nsIDocument> doc;
+  nsresult rv = owner->GetDocument(getter_AddRefs(doc));
+  if (NS_FAILED(rv) || !doc) {
+    return NS_ERROR_FAILURE;
   }
 
-  return NS_ERROR_FAILURE;
+  nsPIDOMWindowOuter *window = doc->GetWindow();
+  if (!window) {
+    return NS_ERROR_FAILURE;
+  }
+
+  nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(window);
+  nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(webNav);
+  if (!ir) {
+    return NS_ERROR_FAILURE;
+  }
+
+  return ir->GetInterface(aIID, result);
 }
 
 NS_IMETHODIMP
 nsPluginStreamListenerPeer::GetInterface(const nsIID& aIID, void** result)
 {
   // Provide nsIChannelEventSink ourselves, otherwise let our document's
   // script global object owner provide the interface.
   if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {