Bug 854448 - Fix debug-only null-deref in JSFunction::name (r=njn)

--HG--
extra : rebase_source : 421a3c31a108e13cd0d2cbba5bd93afeb0432586
This commit is contained in:
Luke Wagner 2013-03-25 15:12:44 -07:00
parent 097b6f1c77
commit 19eb172321
2 changed files with 33 additions and 1 deletions

View File

@ -99,3 +99,35 @@ function assertTypeFailInEval(str)
assertTypeFailInEval('function f({}) { "use asm"; function g() {} return g }');
assertTypeFailInEval('function f({global}) { "use asm"; function g() {} return g }');
assertTypeFailInEval('function f(global, {imports}) { "use asm"; function g() {} return g }');
function assertLinkFailInEval(str)
{
if (!isAsmJSCompilationAvailable())
return;
var caught = false;
var oldOpts = options("werror");
assertEq(oldOpts.indexOf("werror"), -1);
try {
eval(str);
} catch (e) {
assertEq((''+e).indexOf(ASM_OK_STRING) == -1, false);
caught = true;
}
assertEq(caught, true);
options("werror");
var code = eval(str);
var caught = false;
var oldOpts = options("werror");
assertEq(oldOpts.indexOf("werror"), -1);
try {
code.apply(null, Array.slice(arguments, 1));
} catch (e) {
caught = true;
}
assertEq(caught, true);
options("werror");
}
assertLinkFailInEval('(function(global) { "use asm"; var im=global.Math.imul; function g() {} return g })');

View File

@ -165,7 +165,7 @@ class JSFunction : public JSObject
}
JSAtom *atom() const { return hasGuessedAtom() ? NULL : atom_.get(); }
js::PropertyName *name() const { return hasGuessedAtom() ? NULL : atom_->asPropertyName(); }
js::PropertyName *name() const { return hasGuessedAtom() || !atom_ ? NULL : atom_->asPropertyName(); }
inline void initAtom(JSAtom *atom);
JSAtom *displayAtom() const { return atom_; }