Bug 850534: Crash on Yarr OOM, r=dvander
authorHannes Verschore <hv1989@gmail.com>
Tue, 19 Mar 2013 10:57:28 +0100
changeset 125375 2c41bf87b4e535fa9f5fb4976c5864dc8797a750
parent 125374 96fb830b930da758dba84adf179fb168f2842243
child 125378 55860fd20f67936b871953f0f3c6eba3a0da30a9
child 125381 4f795e7abe83f32d909fff8315900b7cee1ebf99
push id24450
push userryanvm@gmail.com
push dateTue, 19 Mar 2013 13:43:35 +0000
treeherdermozilla-central@2c41bf87b4e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs850534
milestone22.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 850534: Crash on Yarr OOM, r=dvander
js/src/yarr/wtfbridge.h
--- a/js/src/yarr/wtfbridge.h
+++ b/js/src/yarr/wtfbridge.h
@@ -128,18 +128,17 @@ class Ref {
 template<typename T, size_t N = 0>
 class Vector {
   public:
     js::Vector<T, N, js::SystemAllocPolicy> impl;
   public:
     Vector() {}
 
     Vector(const Vector &v) {
-        // XXX yarr-oom
-        (void) append(v);
+        append(v);
     }
 
     size_t size() const {
         return impl.length();
     }
 
     T &operator[](size_t i) {
         return impl[i];
@@ -162,43 +161,43 @@ class Vector {
     }
 
     bool isEmpty() const {
         return impl.empty();
     }
 
     template <typename U>
     void append(const U &u) {
-        // XXX yarr-oom
-        (void) impl.append(static_cast<T>(u));
+        if (!impl.append(static_cast<T>(u)))
+            MOZ_CRASH();
     }
 
     template <size_t M>
     void append(const Vector<T,M> &v) {
-        // XXX yarr-oom
-        (void) impl.append(v.impl);
+        if (!impl.append(v.impl))
+            MOZ_CRASH();
     }
 
     void insert(size_t i, const T& t) {
-        // XXX yarr-oom
-        (void) impl.insert(&impl[i], t);
+        if (!impl.insert(&impl[i], t))
+            MOZ_CRASH();
     }
 
     void remove(size_t i) {
         impl.erase(&impl[i]);
     }
 
     void clear() {
         return impl.clear();
     }
 
     void shrink(size_t newLength) {
-        // XXX yarr-oom
         JS_ASSERT(newLength <= impl.length());
-        (void) impl.resize(newLength);
+        if (!impl.resize(newLength))
+            MOZ_CRASH();
     }
 
     void swap(Vector &other) {
         impl.swap(other.impl);
     }
 
     void deleteAllValues() {
         for (T *p = impl.begin(); p != impl.end(); ++p)
@@ -217,33 +216,33 @@ class Vector<OwnPtr<T> > {
   public:
     Vector() {}
 
     size_t size() const {
         return impl.length();
     }
 
     void append(T *t) {
-        // XXX yarr-oom
-        (void) impl.append(t);
+        if (!impl.append(t))
+            MOZ_CRASH();
     }
 
     PassOwnPtr<T> operator[](size_t i) {
         return PassOwnPtr<T>(impl[i]);
     }
 
     void clear() {
         for (T **p = impl.begin(); p != impl.end(); ++p)
             delete_(*p);
         return impl.clear();
     }
 
     void reserve(size_t capacity) {
-        // XXX yarr-oom
-        (void) impl.reserve(capacity);
+        if (!impl.reserve(capacity))
+            MOZ_CRASH();
     }
 };
 
 template <typename T, size_t N>
 inline void
 deleteAllValues(Vector<T, N> &v) {
     v.deleteAllValues();
 }