Bug 881742: Fix null-deref on OOM (or bad allocation size due to corrupted video) in webrtc upstream code r=jesup
authorAdrian Cruceru <cruceru.adrian@yahoo.com>
Thu, 18 Jun 2015 00:06:36 -0400
changeset 280256 4b670aeb3be80dc306b74e46ef6d6556b02b52e5
parent 280255 9d4f6d787c9f7454de191817feeb3967288a9acf
child 280257 41a555505600e9592daef487debe74c2534b4e11
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs881742
milestone41.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 881742: Fix null-deref on OOM (or bad allocation size due to corrupted video) in webrtc upstream code r=jesup
media/webrtc/trunk/webrtc/common_video/plane.cc
--- a/media/webrtc/trunk/webrtc/common_video/plane.cc
+++ b/media/webrtc/trunk/webrtc/common_video/plane.cc
@@ -38,16 +38,21 @@ int Plane::CreateEmptyPlane(int allocate
 
 int Plane::MaybeResize(int new_size) {
   if (new_size <= 0)
     return -1;
   if (new_size <= allocated_size_)
     return 0;
   scoped_ptr<uint8_t, AlignedFreeDeleter> new_buffer(static_cast<uint8_t*>(
       AlignedMalloc(new_size, kBufferAlignment)));
+
+  if (!new_buffer.get()) {
+    return -1;
+  }
+
   if (buffer_.get()) {
     memcpy(new_buffer.get(), buffer_.get(), plane_size_);
   }
   buffer_.reset(new_buffer.release());
   allocated_size_ = new_size;
   return 0;
 }