Bug 1028802 - Don't dereference null pointer in AlignedArray::Rellaoc. r=jwatt
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 14 Jul 2014 14:06:16 +1200
changeset 214552 dba4eb858d74dcebfe716e47690df69b86079fd9
parent 214551 2c95fdd24a270f20c9dd892b12552f834c4ff444
child 214553 12b60cc85be1719322b6d1ee5efd6fd8d826c336
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1028802
milestone33.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 1028802 - Don't dereference null pointer in AlignedArray::Rellaoc. r=jwatt
gfx/2d/Tools.h
--- a/gfx/2d/Tools.h
+++ b/gfx/2d/Tools.h
@@ -147,16 +147,22 @@ struct AlignedArray
       mStorage = nullptr;
       mPtr = nullptr;
       mCount = 0;
       return;
     }
     // We don't create an array of T here, since we don't want ctors to be
     // invoked at the wrong places if we realign below.
     mStorage = new (std::nothrow) uint8_t[storageByteCount.value()];
+    if (!mStorage) {
+      mStorage = nullptr;
+      mPtr = nullptr;
+      mCount = 0;
+      return;
+    }
     if (uintptr_t(mStorage) % alignment) {
       // Our storage does not start at a <alignment>-byte boundary. Make sure mPtr does!
       mPtr = (T*)(uintptr_t(mStorage) + alignment - (uintptr_t(mStorage) % alignment));
     } else {
       mPtr = (T*)(mStorage);
     }
     // Now that mPtr is pointing to the aligned position we can use placement
     // |operator new| to invoke any ctors at the correct positions. For types