Bug 1149563 - Change bogus ctypes code that modifies a frozen object. r=efaust.

This commit is contained in:
Jason Orendorff 2015-03-28 11:28:06 -05:00
parent 1c594e8314
commit 6089bda802

View File

@ -783,7 +783,7 @@ static const JSFunctionSpec sInt64StaticFunctions[] = {
JS_FN("compare", Int64::Compare, 2, CTYPESFN_FLAGS),
JS_FN("lo", Int64::Lo, 1, CTYPESFN_FLAGS),
JS_FN("hi", Int64::Hi, 1, CTYPESFN_FLAGS),
JS_FN("join", Int64::Join, 2, CTYPESFN_FLAGS),
// "join" is defined specially; see InitInt64Class.
JS_FS_END
};
@ -791,7 +791,7 @@ static const JSFunctionSpec sUInt64StaticFunctions[] = {
JS_FN("compare", UInt64::Compare, 2, CTYPESFN_FLAGS),
JS_FN("lo", UInt64::Lo, 1, CTYPESFN_FLAGS),
JS_FN("hi", UInt64::Hi, 1, CTYPESFN_FLAGS),
JS_FN("join", UInt64::Join, 2, CTYPESFN_FLAGS),
// "join" is defined specially; see InitInt64Class.
JS_FS_END
};
@ -1102,10 +1102,8 @@ InitInt64Class(JSContext* cx,
RootedObject ctor(cx, JS_GetConstructor(cx, prototype));
if (!ctor)
return nullptr;
if (!JS_FreezeObject(cx, ctor))
return nullptr;
// Redefine the 'join' function as an extended native and stash
// Define the 'join' function as an extended native and stash
// ctypes.{Int64,UInt64}.prototype in a reserved slot of the new function.
MOZ_ASSERT(clasp == &sInt64ProtoClass || clasp == &sUInt64ProtoClass);
JSNative native = (clasp == &sInt64ProtoClass) ? Int64::Join : UInt64::Join;
@ -1117,6 +1115,8 @@ InitInt64Class(JSContext* cx,
js::SetFunctionNativeReserved(fun, SLOT_FN_INT64PROTO,
OBJECT_TO_JSVAL(prototype));
if (!JS_FreezeObject(cx, ctor))
return nullptr;
if (!JS_FreezeObject(cx, prototype))
return nullptr;