Bug 1389303 - [2.0] Ensure listener is always cleared after OpenURL call. r=me
☠☠ backed out by c888da43ec37 ☠ ☠
authorEugen Sawin <esawin@mozilla.com>
Thu, 17 Aug 2017 14:34:19 +0200
changeset 424856 901692aa7828bae360c61dc0076678116e6c7c36
parent 424855 b5d33e3a84200f0e5868e3429b5ad581a04441b6
child 424857 e7385dfdb85a979037a95823b6f6ab50cd9d2732
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1389303
milestone57.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 1389303 - [2.0] Ensure listener is always cleared after OpenURL call. r=me
uriloader/exthandler/nsExternalProtocolHandler.cpp
--- a/uriloader/exthandler/nsExternalProtocolHandler.cpp
+++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp
@@ -174,31 +174,30 @@ nsresult nsExtProtocolChannel::OpenURL()
     if (NS_FAILED(rv)) {
       goto finish;
     }
                                                 
     rv = extProtService->LoadURI(mUrl, aggCallbacks);
 
     if (NS_SUCCEEDED(rv) && mListener) {
       RefPtr<nsExtProtocolChannel> self = this;
+      nsCOMPtr<nsIStreamListener> listener = mListener;
       MessageLoop::current()->PostTask(
         NS_NewRunnableFunction(
           "nsExtProtocolChannel::OpenURL",
-          [self]() {
-            self->mListener->OnStartRequest(self, nullptr);
-            self->mListener->OnStopRequest(self, nullptr, self->mStatus);
-            self->mListener = nullptr;
+          [self, listener]() {
+            listener->OnStartRequest(self, nullptr);
+            listener->OnStopRequest(self, nullptr, self->mStatus);
           }));
-    } else {
-      mListener = nullptr;
     }
   }
 
 finish:
   mCallbacks = nullptr;
+  mListener = nullptr;
   return rv;
 }
 
 NS_IMETHODIMP nsExtProtocolChannel::Open(nsIInputStream **_retval)
 {
   return OpenURL();
 }