Bug 1033253 - Null-check the result of JS_GetFunctionId. r=bz

This commit is contained in:
Bobby Holley 2014-07-02 11:02:11 -07:00
parent 9f0550ae71
commit 18dbac65de
3 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,6 @@
const Cu = Components.utils;
function run_test() {
var sb = Cu.Sandbox('http://www.example.com');
var f = Cu.evalInSandbox('var f = function() {}; f;', sb);
do_check_eq(f.name, "");
}

View File

@ -43,6 +43,7 @@ support-files =
[test_bug976151.js]
[test_bug1001094.js]
[test_bug1021312.js]
[test_bug1033253.js]
[test_bug_442086.js]
[test_file.js]
[test_blob.js]

View File

@ -575,8 +575,9 @@ JSXrayTraits::resolveOwnProperty(JSContext *cx, const Wrapper &jsWrapper,
NumberValue(JS_GetFunctionArity(JS_GetObjectFunction(target))));
return true;
} else if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_NAME)) {
RootedString fname(cx, JS_GetFunctionId(JS_GetObjectFunction(target)));
FillPropertyDescriptor(desc, wrapper, JSPROP_PERMANENT | JSPROP_READONLY,
StringValue(JS_GetFunctionId(JS_GetObjectFunction(target))));
fname ? StringValue(fname) : JS_GetEmptyStringValue(cx));
} else if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTOTYPE)) {
// Handle the 'prototype' property to make xrayedGlobal.StandardClass.prototype work.
JSProtoKey standardConstructor = constructorFor(holder);