Bug 978047 -- check for OOM r=h4writer
authorNicholas D. Matsakis <nmatsakis@mozilla.com>
Fri, 28 Feb 2014 06:44:06 -0500
changeset 171497 15061de6e948bb229ad5eb27a0675ba26a4b86e6
parent 171496 44b5ab2ee99c8407db8a0d072b49721af0bbb10e
child 171498 54bf6247cc5f68821f48470cbd9538c4d7cb2b4a
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersh4writer
bugs978047
milestone30.0a1
Bug 978047 -- check for OOM r=h4writer
js/src/builtin/TypedObject.cpp
--- a/js/src/builtin/TypedObject.cpp
+++ b/js/src/builtin/TypedObject.cpp
@@ -889,18 +889,22 @@ StructMetaTypeDescr::layout(JSContext *c
                                      ObjectValue(*fieldOffsetsVec));
     }
 
     // Construct the fieldOffsets and fieldTypes objects:
     // fieldOffsets : { string: integer, ... }
     // fieldTypes : { string: Type, ... }
     RootedObject fieldOffsets(cx);
     fieldOffsets = NewObjectWithProto<JSObject>(cx, nullptr, nullptr, TenuredObject);
+    if (!fieldOffsets)
+        return false;
     RootedObject fieldTypes(cx);
     fieldTypes = NewObjectWithProto<JSObject>(cx, nullptr, nullptr, TenuredObject);
+    if (!fieldTypes)
+        return false;
     for (size_t i = 0; i < typeRepr->fieldCount(); i++) {
         const StructField &field = typeRepr->field(i);
         RootedId fieldId(cx, NameToId(field.propertyName));
 
         // fieldOffsets[id] = offset
         RootedValue offset(cx, NumberValue(field.offset));
         if (!JSObject::defineGeneric(cx, fieldOffsets, fieldId,
                                      offset, nullptr, nullptr,