Bug 1081355 - Fix use-after-free in ClearKeyDecryptor - r=cpearce
authorEdwin Flores <eflores@mozilla.com>
Tue, 14 Oct 2014 11:05:00 +1300
changeset 210249 a9db3f88205e8d53a281b25172c3e354fde6dd9c
parent 210248 9183e31ea8ca05940439902d9804f81586f84986
child 210250 fcbf0749ad4507573769c6e64501f9fc88774a1d
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerscpearce
bugs1081355
milestone35.0a1
Bug 1081355 - Fix use-after-free in ClearKeyDecryptor - r=cpearce
media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
--- a/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
@@ -382,19 +382,20 @@ uint32_t
 ClearKeyDecryptor::AddRef()
 {
   return ++mRefCnt;
 }
 
 uint32_t
 ClearKeyDecryptor::Release()
 {
-  if (!--mRefCnt) {
+  uint32_t newCount = --mRefCnt;
+  if (!newCount) {
     if (mThread) {
       mThread->Post(new DestroyTask(this));
       mThread->Join();
     } else {
       delete this;
     }
   }
 
-  return mRefCnt;
+  return newCount;
 }