Bug 1474007: Null check to prevent crash when ipc::mscom::GetInitialInterceptorForIID fails after PublishTarget. r?aklotz draft
authorJames Teh <jteh@mozilla.com>
Mon, 09 Jul 2018 10:24:20 +1000
changeset 815521 ff633d9021e9afe3ab9114a5b0c952b6057cdc6d
parent 815516 ffb7b5015fc331bdc4c5e6ab52b9de669faa8864
push id115524
push userbmo:jteh@mozilla.com
push dateMon, 09 Jul 2018 02:54:12 +0000
reviewersaklotz
bugs1474007
milestone63.0a1
Bug 1474007: Null check to prevent crash when ipc::mscom::GetInitialInterceptorForIID fails after PublishTarget. r?aklotz PublishTarget calls Unlock on our LiveSetAutolock. It's possible for GetInitialInterceptorForIID to fail after this point. This will cause the failure cleanup code to run, which tries to call Unlock again. However, the previous call to Unlock set mLiveSet to null, and Unlock previously didn't handle this case. Now, unlock is a no-op (in release builds) if it's already been called. MozReview-Commit-ID: 15ffXR6nKqc
ipc/mscom/Interceptor.cpp
--- a/ipc/mscom/Interceptor.cpp
+++ b/ipc/mscom/Interceptor.cpp
@@ -99,18 +99,20 @@ public:
     if (mLiveSet) {
       mLiveSet->Unlock();
     }
   }
 
   void Unlock()
   {
     MOZ_ASSERT(mLiveSet);
-    mLiveSet->Unlock();
-    mLiveSet = nullptr;
+    if (mLiveSet) {
+      mLiveSet->Unlock();
+      mLiveSet = nullptr;
+    }
   }
 
   LiveSetAutoLock(const LiveSetAutoLock& aOther) = delete;
   LiveSetAutoLock(LiveSetAutoLock&& aOther) = delete;
   LiveSetAutoLock& operator=(const LiveSetAutoLock& aOther) = delete;
   LiveSetAutoLock& operator=(LiveSetAutoLock&& aOther) = delete;
 
 private: