Bug 1546191 - Add a null-check for listener call in nsCORSListenerProxy::OnStopRequest to prevent a null-dereference crash. r=michal, a=RyanVM
authorHonza Bambas <honzab.moz@firemni.cz>
Thu, 01 Jan 1970 00:00:00 +0000
changeset 524415 78faebfaa7d90e1ae4515c2e92aae9476a016ac6
parent 524414 35aa29266d1141a5e685f0476fcc76b9c392945d
child 524416 1d4968094d070defcc183b6587fe8594f385b8b6
push id765
push userryanvm@gmail.com
push dateTue, 14 Jan 2020 22:56:39 +0000
treeherdermozilla-esr68@3b3f5444c547 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal, RyanVM
bugs1546191
milestone68.5.0
Bug 1546191 - Add a null-check for listener call in nsCORSListenerProxy::OnStopRequest to prevent a null-dereference crash. r=michal, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D59540
netwerk/protocol/http/nsCORSListenerProxy.cpp
--- a/netwerk/protocol/http/nsCORSListenerProxy.cpp
+++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp
@@ -629,17 +629,27 @@ nsresult nsCORSListenerProxy::CheckReque
 NS_IMETHODIMP
 nsCORSListenerProxy::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) {
   MOZ_ASSERT(mInited, "nsCORSListenerProxy has not been initialized properly");
   nsCOMPtr<nsIStreamListener> listener;
   {
     MutexAutoLock lock(mMutex);
     listener = mOuterListener.forget();
   }
+
+#if defined(FENNEC_NIGHTLY) || defined(FENNEC_BETA)
+  // To workaround bug 1546191 (which is likely harmless) we want to add a
+  // non-null check.  As it's just an Android/Fennec crash, we also don't want
+  // to mask other platforms from possible regressions of this code.
+  nsresult rv =
+      listener ? listener->OnStopRequest(aRequest, aStatusCode) : NS_OK;
+#else
   nsresult rv = listener->OnStopRequest(aRequest, aStatusCode);
+#endif
+
   mOuterNotificationCallbacks = nullptr;
   mHttpChannel = nullptr;
   return rv;
 }
 
 NS_IMETHODIMP
 nsCORSListenerProxy::OnDataAvailable(nsIRequest* aRequest,
                                      nsIInputStream* aInputStream,