Bug 1150966 - Check whether |streams_| is null on stats methods in NrIceMediaStream. r=drno, a=lmandel
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 03 Apr 2015 11:13:44 -0700
changeset 265688 cf63504c26f5bdc18d4e2b0b4a3f287bfcbb8dc9
parent 265687 d3af56f0df91619234f1ee19052bf38acd097202
child 265689 a4373b504af74f356ad352e20fbfe95bfea46e34
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno, lmandel
bugs1150966
milestone39.0a2
Bug 1150966 - Check whether |streams_| is null on stats methods in NrIceMediaStream. r=drno, a=lmandel
media/mtransport/nricemediastream.cpp
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -243,16 +243,20 @@ nsresult NrIceMediaStream::ParseTrickleC
 // Returns NS_ERROR_NOT_AVAILABLE if component is unpaired or disabled.
 nsresult NrIceMediaStream::GetActivePair(int component,
                                          NrIceCandidate **localp,
                                          NrIceCandidate **remotep) {
   int r;
   nr_ice_candidate *local_int;
   nr_ice_candidate *remote_int;
 
+  if (!stream_) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
+
   r = nr_ice_media_stream_get_active(ctx_->peer(),
                                      stream_,
                                      component,
                                      &local_int, &remote_int);
   // If result is R_REJECTED then component is unpaired or disabled.
   if (r == R_REJECTED)
     return NS_ERROR_NOT_AVAILABLE;
 
@@ -276,16 +280,19 @@ nsresult NrIceMediaStream::GetActivePair
 
   return NS_OK;
 }
 
 
 nsresult NrIceMediaStream::GetCandidatePairs(std::vector<NrIceCandidatePair>*
                                              out_pairs) const {
   MOZ_ASSERT(out_pairs);
+  if (!stream_) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
 
   // Get the check_list on the peer stream (this is where the check_list
   // actually lives, not in stream_)
   nr_ice_media_stream* peer_stream;
   int r = nr_ice_peer_ctx_find_pstream(ctx_->peer(), stream_, &peer_stream);
   if (r != 0) {
     return NS_ERROR_FAILURE;
   }
@@ -361,16 +368,20 @@ nsresult NrIceMediaStream::GetDefaultCan
 }
 
 std::vector<std::string> NrIceMediaStream::GetCandidates() const {
   char **attrs = 0;
   int attrct;
   int r;
   std::vector<std::string> ret;
 
+  if (!stream_) {
+    return ret;
+  }
+
   r = nr_ice_media_stream_get_attributes(stream_,
                                          &attrs, &attrct);
   if (r) {
     MOZ_MTLOG(ML_ERROR, "Couldn't get ICE candidates for '"
               << name_ << "'");
     return ret;
   }
 
@@ -407,21 +418,29 @@ static nsresult GetCandidatesFromStream(
     comp=STAILQ_NEXT(comp,entry);
   }
 
   return NS_OK;
 }
 
 nsresult NrIceMediaStream::GetLocalCandidates(
     std::vector<NrIceCandidate>* candidates) const {
+  if (!stream_) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
+
   return GetCandidatesFromStream(stream_, candidates);
 }
 
 nsresult NrIceMediaStream::GetRemoteCandidates(
     std::vector<NrIceCandidate>* candidates) const {
+  if (!stream_) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
+
   nr_ice_media_stream* peer_stream;
   int r = nr_ice_peer_ctx_find_pstream(ctx_->peer(), stream_, &peer_stream);
   if (r != 0) {
     return NS_ERROR_FAILURE;
   }
 
   return GetCandidatesFromStream(peer_stream, candidates);
 }