# HG changeset patch # User Tooru Fujisawa # Date 1451931684 -32400 # Tue Jan 05 03:21:24 2016 +0900 # Node ID 6fff989282435e6e9a0d2c4047aca1aabe797c15 # Parent c57006f58b390d1d4020e4262cb3aedfc2734b55 Bug 1180290 - Part 2: Handle prefix in DefinePropertyById. diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2112,31 +2112,36 @@ DefinePropertyById(JSContext* cx, Handle // If !(attrs & JSPROP_PROPOP_ACCESSORS), then either getter/setter are both // possibly-null JSNatives (or possibly-null JSFunction* if JSPROP_GETTER or // JSPROP_SETTER is appropriately set), or both are the well-known property // stubs. The subsequent block must handle only the first of these cases, // so carefully exclude the latter case. if (!(attrs & JSPROP_PROPOP_ACCESSORS) && getter != JS_PropertyStub && setter != JS_StrictPropertyStub) { - RootedAtom atom(cx, JSID_IS_ATOM(id) ? JSID_TO_ATOM(id) : nullptr); if (getter && !(attrs & JSPROP_GETTER)) { + RootedAtom atom(cx, IdToFunctionName(cx, id, "get")); + if (!atom) + return false; JSFunction* getobj = NewNativeFunction(cx, (Native) getter, 0, atom); if (!getobj) return false; if (get.info) getobj->setJitInfo(get.info); getter = JS_DATA_TO_FUNC_PTR(GetterOp, getobj); attrs |= JSPROP_GETTER; } if (setter && !(attrs & JSPROP_SETTER)) { // Root just the getter, since the setter is not yet a JSObject. AutoRooterGetterSetter getRoot(cx, JSPROP_GETTER, &getter, nullptr); + RootedAtom atom(cx, IdToFunctionName(cx, id, "set")); + if (!atom) + return false; JSFunction* setobj = NewNativeFunction(cx, (Native) setter, 1, atom); if (!setobj) return false; if (set.info) setobj->setJitInfo(set.info); setter = JS_DATA_TO_FUNC_PTR(SetterOp, setobj);