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 356567 1b808c63a394eabe5251b3849332d39bb57e753a
parent 356566 b85b4f18f956a51d3b63a73b058006d81aa22624
child 356568 f89db30c48bf6b0d1078dd56f56b9003cafe94d1
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1301124
milestone51.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 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: