Bug 1457073 - Fix a leak in WorkerEventTarget::Dispatch() about how already_AddRefed<> params are handled, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 26 Apr 2018 11:41:15 +0200
changeset 469290 d50f31ee0a5bb8d04034cbd6451de327a6805517
parent 469289 64b83e067db211768e1d9c0f086ec46513bac4cf
child 469291 8df37ea84bf3b5830949c8ce7d6d32242c7eebca
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1457073
milestone61.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 1457073 - Fix a leak in WorkerEventTarget::Dispatch() about how already_AddRefed<> params are handled, r=smaug
dom/workers/WorkerEventTarget.cpp
--- a/dom/workers/WorkerEventTarget.cpp
+++ b/dom/workers/WorkerEventTarget.cpp
@@ -96,24 +96,24 @@ WorkerEventTarget::DispatchFromScript(ns
   nsCOMPtr<nsIRunnable> runnable(aRunnable);
   return Dispatch(runnable.forget(), aFlags);
 }
 
 NS_IMETHODIMP
 WorkerEventTarget::Dispatch(already_AddRefed<nsIRunnable> aRunnable,
                             uint32_t aFlags)
 {
+  nsCOMPtr<nsIRunnable> runnable(aRunnable);
+
   MutexAutoLock lock(mMutex);
 
   if (!mWorkerPrivate) {
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr<nsIRunnable> runnable(aRunnable);
-
   if (mBehavior == Behavior::Hybrid) {
     RefPtr<WorkerRunnable> r =
       mWorkerPrivate->MaybeWrapAsWorkerRunnable(runnable.forget());
     if (r->Dispatch()) {
       return NS_OK;
     }
 
     runnable = r.forget();