Bug 990806, part 2 - Fix "Assertion failure: gGotError, at js/src/shell/js.cpp:448" after OOM in the shell by setting gGotError from an out-of-memory callback. r=terrence.

This commit is contained in:
Jason Orendorff 2014-04-04 17:03:12 -05:00
parent 78905a389b
commit a2779e00d1

View File

@ -4923,6 +4923,16 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
}
}
static void
my_OOMCallback(JSContext *cx)
{
// If a script is running, the engine is about to throw the string "out of
// memory", which may or may not be caught. Otherwise the engine will just
// unwind and return null/false, with no exception set.
if (!JS_IsRunning(cx))
gGotError = true;
}
static bool
global_enumerate(JSContext *cx, HandleObject obj)
{
@ -6154,6 +6164,7 @@ main(int argc, char **argv, char **envp)
if (!rt)
return 1;
JS::SetOutOfMemoryCallback(rt, my_OOMCallback);
if (!SetRuntimeOptions(rt, op))
return 1;