Bug 1301124 - Make sure to actually hold a death grip on callback in ErrorNotifier::Run() and CallbackResultNotifier::Run(), r=smaug
authorMichael Layzell <michael@thelayzells.com>
Wed, 07 Sep 2016 13:18:59 -0400
changeset 313076 1b808c63a394eabe5251b3849332d39bb57e753a
parent 313075 b85b4f18f956a51d3b63a73b058006d81aa22624
child 313077 f89db30c48bf6b0d1078dd56f56b9003cafe94d1
push id20479
push userkwierso@gmail.com
push dateThu, 08 Sep 2016 01:08:46 +0000
treeherderfx-team@fb7c6b034329 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1301124
milestone51.0a1
Bug 1301124 - Make sure to actually hold a death grip on callback in ErrorNotifier::Run() and CallbackResultNotifier::Run(), r=smaug MozReview-Commit-ID: 28K4VmKoqgO
storage/mozStorageAsyncStatementExecution.cpp
--- a/storage/mozStorageAsyncStatementExecution.cpp
+++ b/storage/mozStorageAsyncStatementExecution.cpp
@@ -65,17 +65,20 @@ public:
   NS_IMETHOD Run() override
   {
     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() override
   {
     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: