Bug 1362165: P1. Fix potential race accessing members. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 05 May 2017 17:51:08 +0200
changeset 409393 20e01cb7989d63219c2acfb611cf9b25a0135cee
parent 409392 df0ddb9c9befc73c6ee4c446087016f7597d2316
child 409394 c89c6c8630f132296b2e2edbba4239a8ad7a1075
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1362165
milestone55.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 1362165: P1. Fix potential race accessing members. r=gerald MozReview-Commit-ID: 9sXU2ZFKmJZ
dom/media/mediasource/MediaSourceDemuxer.cpp
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -197,21 +197,24 @@ void
 MediaSourceDemuxer::DoDetachSourceBuffer(TrackBuffersManager* aSourceBuffer)
 {
   MOZ_ASSERT(OnTaskQueue());
   for (uint32_t i = 0; i < mSourceBuffers.Length(); i++) {
     if (mSourceBuffers[i].get() == aSourceBuffer) {
       mSourceBuffers.RemoveElementAt(i);
     }
   }
-  if (aSourceBuffer == mAudioTrack) {
-    mAudioTrack = nullptr;
-  }
-  if (aSourceBuffer == mVideoTrack) {
-    mVideoTrack = nullptr;
+  {
+    MonitorAutoLock mon(mMonitor);
+    if (aSourceBuffer == mAudioTrack) {
+      mAudioTrack = nullptr;
+    }
+    if (aSourceBuffer == mVideoTrack) {
+      mVideoTrack = nullptr;
+    }
   }
   ScanSourceBuffersForContent();
 }
 
 TrackInfo*
 MediaSourceDemuxer::GetTrackInfo(TrackType aTrack)
 {
   MonitorAutoLock mon(mMonitor);