Bug 1301124 - Make sure to actually hold a death grip on callback in ErrorNotifier::Run() and CallbackResultNotifier::Run(). r=smaug, a=ritu
authorMichael Layzell <michael@thelayzells.com>
Wed, 07 Sep 2016 13:18:59 -0400
changeset 350371 f6f6a67f5f1d1f305fba492b9e30e7570d3a64af
parent 350370 65b9f5cea747a0815157758fb7c4a837910dac8f
child 350372 917fe502471a3e6846e2de665a7d940894937249
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, ritu
bugs1301124
milestone50.0
Bug 1301124 - Make sure to actually hold a death grip on callback in ErrorNotifier::Run() and CallbackResultNotifier::Run(). r=smaug, a=ritu MozReview-Commit-ID: 28K4VmKoqgO
storage/mozStorageAsyncStatementExecution.cpp
--- a/storage/mozStorageAsyncStatementExecution.cpp
+++ b/storage/mozStorageAsyncStatementExecution.cpp
@@ -65,17 +65,20 @@ public:
   NS_IMETHOD Run()
   {
     NS_ASSERTION(mCallback, "Trying to notify about results without a callback!");
 
     if (mEventStatus->shouldNotify()) {
       // Hold a strong reference to the callback while notifying it, so that if
       // it spins the event loop, the callback won't be released and freed out
       // from under us.
-      nsCOMPtr<mozIStorageStatementCallback> callback = mCallback;
+      //
+      // We can't put it in a nsCOMPtr, as sometimes mCallback doesn't
+      // QueryInterface to a mozIStorageStatementCallback, despite being one
+      RefPtr<mozIStorageStatementCallback> callback = mCallback;
 
       (void)callback->HandleResult(mResults);
     }
 
     return NS_OK;
   }
 
 private:
@@ -100,17 +103,20 @@ public:
   }
 
   NS_IMETHOD Run()
   {
     if (mEventStatus->shouldNotify() && mCallback) {
       // Hold a strong reference to the callback while notifying it, so that if
       // it spins the event loop, the callback won't be released and freed out
       // from under us.
-      nsCOMPtr<mozIStorageStatementCallback> callback = mCallback;
+      //
+      // We can't put it in a nsCOMPtr, as sometimes mCallback doesn't
+      // QueryInterface to a mozIStorageStatementCallback, despite being one
+      RefPtr<mozIStorageStatementCallback> callback = mCallback;
 
       (void)callback->HandleError(mErrorObj);
     }
 
     return NS_OK;
   }
 
 private: