Bug 1270135 - Initialize the frame count properly to avoid passing a random value down the callback. r?kinetik draft
authorPaul Adenot <paul@paul.cx>
Wed, 04 May 2016 17:08:13 +0200
changeset 363396 fb47034b6f2108ba5bd9c7f4cba5d42590235152
parent 363270 95a208689737a3987e5519ae1cd2fb7efb05cfdf
child 520013 76ba8752bb85475dea840571097d3fc05c868be5
push id17177
push userpaul@paul.cx
push dateWed, 04 May 2016 15:08:39 +0000
reviewerskinetik
bugs1270135, 1268719
milestone49.0a1
Bug 1270135 - Initialize the frame count properly to avoid passing a random value down the callback. r?kinetik When draining (probable considering that it's trying to shut down the stream, see the other thread), we can end up returning `true` from `get_output_buffer` without touching the `frame_count`. `output_frames` is not zero because it's containing garbage. Also `output_buffer` has probably an invalid value. We probably allocate a massive buffer because we find that we don't have enough input data in the linarized input buffer, possibly OOMing in the process. If not, we call the call back, run the graph, and end up crashing somewhere random in the MSG, possibly exactly at this crash location because we're shutting down so no streams are writing to the output buffer until the logic that fills in silence at the end. This might fix bug 1268719, not sure. MozReview-Commit-ID: LMTEPIOxvf8
media/libcubeb/src/cubeb_wasapi.cpp
--- a/media/libcubeb/src/cubeb_wasapi.cpp
+++ b/media/libcubeb/src/cubeb_wasapi.cpp
@@ -691,18 +691,18 @@ bool get_output_buffer(cubeb_stream * st
 
 /**
  * This function gets input data from a input device, and pass it along with an
  * output buffer to the resamplers.  */
 bool
 refill_callback_duplex(cubeb_stream * stm)
 {
   HRESULT hr;
-  float * output_buffer;
-  size_t output_frames;
+  float * output_buffer = nullptr;
+  size_t output_frames = 0;
   bool rv;
 
   XASSERT(has_input(stm) && has_output(stm));
 
   rv = get_input_buffer(stm);
   if (!rv) {
     return rv;
   }