Bug 876856 - Check if PeerConnection is closed before accessing MediaStreamList. r=ekr, a=akeybl
authorRandell Jesup <rjesup@jesup.org>
Thu, 30 May 2013 16:48:31 -0400
changeset 138635 7c64168fea7b
parent 138634 d938a837b76a
child 138636 beaa70e61024
push id3832
push userryanvm@gmail.com
push date2013-06-03 21:10 +0000
treeherdermozilla-aurora@beaa70e61024 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersekr, akeybl
bugs876856
milestone23.0a2
Bug 876856 - Check if PeerConnection is closed before accessing MediaStreamList. r=ekr, a=akeybl
media/webrtc/signaling/src/peerconnection/MediaStreamList.cpp
--- a/media/webrtc/signaling/src/peerconnection/MediaStreamList.cpp
+++ b/media/webrtc/signaling/src/peerconnection/MediaStreamList.cpp
@@ -72,26 +72,33 @@ GetStreamFromInfo(T* info, bool& found)
 
   found = true;
   return info->GetMediaStream();
 }
 
 DOMMediaStream*
 MediaStreamList::IndexedGetter(uint32_t index, bool& found)
 {
+  if (!mPeerConnection->media()) { // PeerConnection closed
+    found = false;
+    return nullptr;
+  }
   if (mType == Local) {
     return GetStreamFromInfo(mPeerConnection->media()->
       GetLocalStream(index), found);
   }
 
   return GetStreamFromInfo(mPeerConnection->media()->
     GetRemoteStream(index), found);
 }
 
 uint32_t
 MediaStreamList::Length()
 {
+  if (!mPeerConnection->media()) { // PeerConnection closed
+    return 0;
+  }
   return mType == Local ? mPeerConnection->media()->LocalStreamsLength() :
       mPeerConnection->media()->RemoteStreamsLength();
 }
 
 } // namespace dom
 } // namespace mozilla