Bug 1335460 - release globals properly when GetFilesHelper is destroyed on the main thread; r=smaug
authorNathan Froyd <froydnj@mozilla.com>
Tue, 31 Jan 2017 13:08:28 -0500
changeset 360895 8d2a9160dcafe13d28099a643212f784b5124e8c
parent 360894 fbe43964eb8d1595bb67fd679da69053de3a2015
child 360896 895ddf282ead4d4533313c43b7cfa0aa218981e3
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1335460
milestone54.0a1
Bug 1335460 - release globals properly when GetFilesHelper is destroyed on the main thread; r=smaug
dom/filesystem/GetFilesHelper.cpp
--- a/dom/filesystem/GetFilesHelper.cpp
+++ b/dom/filesystem/GetFilesHelper.cpp
@@ -20,22 +20,23 @@ class ReleaseRunnable final : public Run
 {
 public:
   static void
   MaybeReleaseOnMainThread(nsTArray<RefPtr<Promise>>& aPromises,
                            nsTArray<RefPtr<GetFilesCallback>>& aCallbacks,
                            Sequence<RefPtr<File>>& aFiles,
                            already_AddRefed<nsIGlobalObject> aGlobal)
   {
+    nsCOMPtr<nsIGlobalObject> global(aGlobal);
     if (NS_IsMainThread()) {
       return;
     }
 
     RefPtr<ReleaseRunnable> runnable =
-      new ReleaseRunnable(aPromises, aCallbacks, aFiles, Move(aGlobal));
+      new ReleaseRunnable(aPromises, aCallbacks, aFiles, global.forget());
     NS_DispatchToMainThread(runnable);
   }
 
   NS_IMETHOD
   Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());