Bug 1265036 - Use NS_ABORT_OOM() if try_realloc() fails. r=billm
authorAndrew McCreight <continuation@gmail.com>
Sat, 16 Apr 2016 10:47:46 -0700
changeset 331409 1a309a682f19420bfbd04d219dbb3e1d95bfdda0
parent 331408 aaa5e560ed433089e55a0e3f5570bb8adc39aa50
child 331410 533daf1ab8c9ea5009f45569639b9e4e86b27e4e
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1265036
milestone48.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 1265036 - Use NS_ABORT_OOM() if try_realloc() fails. r=billm This will give the crash a proper OOM annotation.
ipc/chromium/src/base/buffer.cc
--- a/ipc/chromium/src/base/buffer.cc
+++ b/ipc/chromium/src/base/buffer.cc
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "buffer.h"
+#include "nsDebug.h"
 
 Buffer::Buffer()
  : mBuffer(nullptr),
    mSize(0),
    mReserved(0)
 {
 }
 
@@ -54,17 +55,19 @@ Buffer::try_realloc(size_t newlength)
   if (buffer || !newlength) {
     mBuffer = buffer;
     mReserved = newlength;
     return;
   }
 
   // If we're growing the buffer, crash. If we're shrinking, then we continue to
   // use the old (larger) buffer.
-  MOZ_RELEASE_ASSERT(newlength <= mReserved);
+  if (newlength > mReserved) {
+    NS_ABORT_OOM(newlength);
+  }
 }
 
 void
 Buffer::append(const char* bytes, size_t length)
 {
   if (mSize + length > mReserved) {
     try_realloc(mSize + length);
   }