Bug 1266260: P2. Check for OOM. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 11 May 2016 12:15:36 +0200
changeset 296937 b2ed54d8bba5e336a21bfc3237b07226314bcd7d
parent 296936 afe186de263fa4ddd827c5b9aa6520cc23a0042b
child 296938 9a00b5f6a6dcb746df67b3639d1e4196617df20e
push id76530
push usercbook@mozilla.com
push dateWed, 11 May 2016 10:17:12 +0000
treeherdermozilla-inbound@9a00b5f6a6dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1266260
milestone49.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 1266260: P2. Check for OOM. r=gerald Additionally, indicate in clearer fashion where setting length can't fail. MozReview-Commit-ID: LSZtCclqhK1
dom/media/AudioConverter.h
--- a/dom/media/AudioConverter.h
+++ b/dom/media/AudioConverter.h
@@ -150,36 +150,38 @@ public:
     // Perform the downmixing / reordering in temporary buffer.
     size_t frames = SamplesInToFrames(aBuffer.Length());
     AlignedBuffer<Value> temp1;
     if (!temp1.SetLength(FramesOutToSamples(frames))) {
       return AudioDataBuffer<Format, Value>(Move(temp1));
     }
     frames = ProcessInternal(temp1.Data(), aBuffer.Data(), frames);
     if (mIn.Rate() == mOut.Rate()) {
-      temp1.SetLength(FramesOutToSamples(frames));
+      MOZ_ALWAYS_TRUE(temp1.SetLength(FramesOutToSamples(frames)));
       return AudioDataBuffer<Format, Value>(Move(temp1));
     }
 
     // At this point, temp1 contains the buffer reordered and downmixed.
     // If we are downsampling we can re-use it.
     AlignedBuffer<Value>* outputBuffer = &temp1;
     AlignedBuffer<Value> temp2;
     if (!frames || mOut.Rate() > mIn.Rate()) {
       // We are upsampling or about to drain, we can't work in place.
       // Allocate another temporary buffer where the upsampling will occur.
-      temp2.SetLength(FramesOutToSamples(ResampleRecipientFrames(frames)));
+      if (!temp2.SetLength(FramesOutToSamples(ResampleRecipientFrames(frames)))) {
+        return AudioDataBuffer<Format, Value>(Move(temp2));
+      }
       outputBuffer = &temp2;
     }
     if (!frames) {
       frames = DrainResampler(outputBuffer->Data());
     } else {
       frames = ResampleAudio(outputBuffer->Data(), temp1.Data(), frames);
     }
-    outputBuffer->SetLength(FramesOutToSamples(frames));
+    MOZ_ALWAYS_TRUE(outputBuffer->SetLength(FramesOutToSamples(frames)));
     return AudioDataBuffer<Format, Value>(Move(*outputBuffer));
   }
 
   // Attempt to convert the AudioDataBuffer in place.
   // Will return 0 if the conversion wasn't possible.
   template <typename Value>
   size_t Process(Value* aBuffer, size_t aFrames)
   {