Bug 959787 - Fix OOM crash added by previous patch r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 28 Jan 2014 10:35:07 +0000
changeset 165590 29a9828e695f4a1d1d102e255dcc574cf40e3d3f
parent 165589 64bf5ddbf7544a3a58912921486d4da75d100e13
child 165591 e10ef633ded9c3bd295c8403ebbaa1ba68dae246
push id4623
push userryanvm@gmail.com
push dateTue, 28 Jan 2014 21:48:39 +0000
treeherderfx-team@7e79536aca0a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs959787
milestone29.0a1
Bug 959787 - Fix OOM crash added by previous patch r=terrence
js/src/jsapi.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3489,27 +3489,31 @@ JS_SetElement(JSContext *cx, HandleObjec
     RootedValue value(cx, NumberValue(v));
     return SetElement(cx, obj, index, &value);
 }
 
 JS_PUBLIC_API(bool)
 JS_SetProperty(JSContext *cx, HandleObject obj, const char *name, HandleValue v)
 {
     JSAtom *atom = Atomize(cx, name, strlen(name));
+    if (!atom)
+        return false;
     RootedId id(cx, AtomToId(atom));
-    return atom && JS_SetPropertyById(cx, obj, id, v);
+    return JS_SetPropertyById(cx, obj, id, v);
 }
 
 JS_PUBLIC_API(bool)
 JS_SetUCProperty(JSContext *cx, HandleObject obj, const jschar *name, size_t namelen,
                  HandleValue v)
 {
     JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
+    if (!atom)
+        return false;
     RootedId id(cx, AtomToId(atom));
-    return atom && JS_SetPropertyById(cx, obj, id, v);
+    return JS_SetPropertyById(cx, obj, id, v);
 }
 
 JS_PUBLIC_API(bool)
 JS_DeletePropertyById2(JSContext *cx, HandleObject obj, HandleId id, bool *result)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj, id);