Bug 1303419 - Fix nullptr crash in audio gUM (beta patch). r=drno, a=ritu
authorRandell Jesup <rjesup@jesup.org>
Wed, 21 Sep 2016 12:31:37 -0400
changeset 350344 eb11246a0e01ac22ccb15dff47616d9e7e6d5dc2
parent 350343 91faf7ec36cd18a8ebdc0e2edac966e5bbb15da2
child 350345 178bd0d028dd9ae399822a4c1d1677dc6348e57d
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno, ritu
bugs1303419
milestone50.0
Bug 1303419 - Fix nullptr crash in audio gUM (beta patch). r=drno, a=ritu MozReview-Commit-ID: Am9FTMcTCzG
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -814,18 +814,23 @@ MediaEngineWebRTCMicrophoneSource::Shutd
     MOZ_ASSERT(mState == kStopped);
   }
 
   while (mRegisteredHandles.Length()) {
     MOZ_ASSERT(mState == kAllocated || mState == kStopped);
     Deallocate(nullptr); // XXX Extend concurrent constraints code to mics.
   }
 
-  FreeChannel();
-  DeInitEngine();
+  if (mState != kReleased) {
+    FreeChannel();
+    MOZ_ASSERT(sChannelsOpen > 0);
+    if (--sChannelsOpen == 0) {
+      DeInitEngine();
+    }
+  }
 
   mAudioInput = nullptr;
 }
 
 typedef int16_t sample;
 
 void
 MediaEngineWebRTCMicrophoneSource::Process(int channel,