Bug 860435 - Don't use an iterator that's already at the end of the stack. r=terrence

This commit is contained in:
Blake Kaplan 2013-05-28 17:35:44 -07:00
parent 946902d96e
commit 6f75922493
3 changed files with 28 additions and 1 deletions

View File

@ -26,6 +26,7 @@ CPP_SOURCES += [
'testDefineProperty.cpp',
'testEnclosingFunction.cpp',
'testErrorCopying.cpp',
'testException.cpp',
'testExternalStrings.cpp',
'testFindSCCs.cpp',
'testFuncCallback.cpp',

View File

@ -0,0 +1,26 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "tests.h"
BEGIN_TEST(testException_bug860435)
{
JS::RootedValue fun(cx);
EVAL("ReferenceError", fun.address());
CHECK(fun.isObject());
JS::RootedValue v(cx);
JS_CallFunctionValue(cx, global, fun, 0, v.address(), v.address());
CHECK(v.isObject());
JS_GetProperty(cx, &v.toObject(), "stack", v.address());
CHECK(v.isString());
return true;
}
END_TEST(testException_bug860435)

View File

@ -571,7 +571,7 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
NonBuiltinScriptFrameIter iter(cx);
/* Set the 'fileName' property. */
RootedScript script(cx, iter.script());
RootedScript script(cx, iter.done() ? NULL : iter.script());
RootedString filename(cx);
if (args.length() > 1) {
filename = ToString<CanGC>(cx, args[1]);