Bug 1143278 - Add more null checks in gmp-clearkey's decoders. r=edwin, a=sledru
authorChris Pearce <cpearce@mozilla.com>
Mon, 13 Apr 2015 13:39:49 +1200
changeset 258471 5779893b39a5
parent 258470 f9f96ba1dbdb
child 258472 dfce472edd1e
push id4676
push userryanvm@gmail.com
push date2015-04-15 02:06 +0000
treeherdermozilla-beta@91df81e2edac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin, sledru
bugs1143278
milestone38.0
Bug 1143278 - Add more null checks in gmp-clearkey's decoders. r=edwin, a=sledru
media/gmp-clearkey/0.1/AudioDecoder.cpp
media/gmp-clearkey/0.1/VideoDecoder.cpp
--- a/media/gmp-clearkey/0.1/AudioDecoder.cpp
+++ b/media/gmp-clearkey/0.1/AudioDecoder.cpp
@@ -31,17 +31,19 @@ AudioDecoder::AudioDecoder(GMPAudioHost 
   , mMutex(nullptr)
   , mNumInputTasks(0)
   , mHasShutdown(false)
 {
 }
 
 AudioDecoder::~AudioDecoder()
 {
-  mMutex->Destroy();
+  if (mMutex) {
+    mMutex->Destroy();
+  }
 }
 
 void
 AudioDecoder::InitDecode(const GMPAudioCodec& aConfig,
                          GMPAudioDecoderCallback* aCallback)
 {
   mCallback = aCallback;
   assert(mCallback);
@@ -218,18 +220,22 @@ AudioDecoder::MFToGMPSample(IMFSample* a
   aOutput->SetRate(mDecoder->Rate());
 
   return S_OK;
 }
 
 void
 AudioDecoder::Reset()
 {
-  mDecoder->Reset();
-  mCallback->ResetComplete();
+  if (mDecoder) {
+    mDecoder->Reset();
+  }
+  if (mCallback) {
+    mCallback->ResetComplete();
+  }
 }
 
 void
 AudioDecoder::DrainTask()
 {
   mDecoder->Drain();
 
   // Return any pending output.
@@ -243,16 +249,19 @@ AudioDecoder::DrainTask()
     }
   }
   MaybeRunOnMainThread(WrapTask(mCallback, &GMPAudioDecoderCallback::DrainComplete));
 }
 
 void
 AudioDecoder::Drain()
 {
+  if (!mDecoder) {
+    return;
+  }
   EnsureWorker();
   mWorkerThread->Post(WrapTask(this,
                                &AudioDecoder::DrainTask));
 }
 
 void
 AudioDecoder::DecodingComplete()
 {
--- a/media/gmp-clearkey/0.1/VideoDecoder.cpp
+++ b/media/gmp-clearkey/0.1/VideoDecoder.cpp
@@ -35,17 +35,19 @@ VideoDecoder::VideoDecoder(GMPVideoHost 
   , mNumInputTasks(0)
   , mSentExtraData(false)
   , mHasShutdown(false)
 {
 }
 
 VideoDecoder::~VideoDecoder()
 {
-  mMutex->Destroy();
+  if (mMutex) {
+    mMutex->Destroy();
+  }
 }
 
 void
 VideoDecoder::InitDecode(const GMPVideoCodec& aCodecSettings,
                          const uint8_t* aCodecSpecific,
                          uint32_t aCodecSpecificLength,
                          GMPVideoDecoderCallback* aCallback,
                          int32_t aCoreCount)
@@ -327,18 +329,22 @@ VideoDecoder::SampleToVideoFrame(IMFSamp
   aVideoFrame->SetDuration(HNsToUsecs(hns));
 
   return S_OK;
 }
 
 void
 VideoDecoder::Reset()
 {
-  mDecoder->Reset();
-  mCallback->ResetComplete();
+  if (mDecoder) {
+    mDecoder->Reset();
+  }
+  if (mCallback) {
+    mCallback->ResetComplete();
+  }
 }
 
 void
 VideoDecoder::DrainTask()
 {
   mDecoder->Drain();
 
   // Return any pending output.
@@ -359,16 +365,22 @@ VideoDecoder::DrainTask()
     }
   }
   MaybeRunOnMainThread(WrapTask(mCallback, &GMPVideoDecoderCallback::DrainComplete));
 }
 
 void
 VideoDecoder::Drain()
 {
+  if (!mDecoder) {
+    if (mCallback) {
+      mCallback->DrainComplete();
+    }
+    return;
+  }
   EnsureWorker();
   mWorkerThread->Post(WrapTask(this,
                                &VideoDecoder::DrainTask));
 }
 
 void
 VideoDecoder::DecodingComplete()
 {