Bug 1143339: Part1. Ensure successive calls to Shutdown() won't potentially crash. r=cpearce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 16 Mar 2015 08:48:29 +1100
changeset 233879 6c7e269c8707b23cbf4985339cee2caa761360ea
parent 233878 df82a0b667bbb90ad257aaf458d9e80df1d2c3df
child 233880 1c8639568d8b2bb5a6b2e907c300112942bfb07f
push id28426
push usercbook@mozilla.com
push dateTue, 17 Mar 2015 10:46:54 +0000
treeherdermozilla-central@008b3f65a7e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1143339
milestone39.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 1143339: Part1. Ensure successive calls to Shutdown() won't potentially crash. r=cpearce
dom/media/fmp4/AVCCDecoderModule.cpp
--- a/dom/media/fmp4/AVCCDecoderModule.cpp
+++ b/dom/media/fmp4/AVCCDecoderModule.cpp
@@ -131,17 +131,19 @@ AVCCMediaDataDecoder::Drain()
   }
   return mLastError;
 }
 
 nsresult
 AVCCMediaDataDecoder::Shutdown()
 {
   if (mDecoder) {
-    return mDecoder->Shutdown();
+    nsresult rv = mDecoder->Shutdown();
+    mDecoder = nullptr;
+    return rv;
   }
   return NS_OK;
 }
 
 bool
 AVCCMediaDataDecoder::IsWaitingMediaResources()
 {
   if (mDecoder) {
@@ -160,20 +162,17 @@ void
 AVCCMediaDataDecoder::AllocateMediaResources()
 {
   // Nothing to do, decoder will be allocated on the fly when required.
 }
 
 void
 AVCCMediaDataDecoder::ReleaseMediaResources()
 {
-  if (mDecoder) {
-    mDecoder->Shutdown();
-    mDecoder = nullptr;
-  }
+  Shutdown();
 }
 
 nsresult
 AVCCMediaDataDecoder::CreateDecoder()
 {
   if (!mp4_demuxer::AnnexB::HasSPS(mCurrentConfig.extra_data)) {
     // nothing found yet, will try again later
     return NS_ERROR_NOT_INITIALIZED;