зеркало из https://github.com/mozilla/gecko-dev.git
Bug 609141 - Compartments mismatch in jsdScript::GetFunctionSource. r=sayrer
This commit is contained in:
Родитель
e0f6235585
Коммит
d21e32b8fa
|
@ -60,6 +60,9 @@
|
||||||
#include "nsIScriptContext.h"
|
#include "nsIScriptContext.h"
|
||||||
#include "nsIJSContextStack.h"
|
#include "nsIJSContextStack.h"
|
||||||
|
|
||||||
|
/* XXX private JS headers. */
|
||||||
|
#include "jscompartment.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* defining CAUTIOUS_SCRIPTHOOK makes jsds disable GC while calling out to the
|
* defining CAUTIOUS_SCRIPTHOOK makes jsds disable GC while calling out to the
|
||||||
* script hook. This was a hack to avoid some js engine problems that should
|
* script hook. This was a hack to avoid some js engine problems that should
|
||||||
|
@ -1319,10 +1322,14 @@ jsdScript::GetFunctionSource(nsAString & aFunctionSource)
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
JSString *jsstr;
|
JSString *jsstr;
|
||||||
if (fun)
|
if (fun) {
|
||||||
|
JSAutoEnterCompartment ac;
|
||||||
|
if (!ac.enter(cx, JS_GetFunctionObject(fun)))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
jsstr = JS_DecompileFunction (cx, fun, 4);
|
jsstr = JS_DecompileFunction (cx, fun, 4);
|
||||||
else {
|
} else {
|
||||||
JSScript *script = JSD_GetJSScript (mCx, mScript);
|
JSScript *script = JSD_GetJSScript (mCx, mScript);
|
||||||
|
js::SwitchToCompartment sc(cx, script->compartment);
|
||||||
jsstr = JS_DecompileScript (cx, script, "ppscript", 4);
|
jsstr = JS_DecompileScript (cx, script, "ppscript", 4);
|
||||||
}
|
}
|
||||||
if (!jsstr)
|
if (!jsstr)
|
||||||
|
|
|
@ -4744,7 +4744,10 @@ JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, uintN inde
|
||||||
JSString *str;
|
JSString *str;
|
||||||
|
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
assertSameCompartment(cx, script);
|
#ifdef DEBUG
|
||||||
|
if (cx->compartment != script->compartment)
|
||||||
|
CompartmentChecker::fail(cx->compartment, script->compartment);
|
||||||
|
#endif
|
||||||
jp = js_NewPrinter(cx, name, NULL,
|
jp = js_NewPrinter(cx, name, NULL,
|
||||||
indent & ~JS_DONT_PRETTY_PRINT,
|
indent & ~JS_DONT_PRETTY_PRINT,
|
||||||
!(indent & JS_DONT_PRETTY_PRINT),
|
!(indent & JS_DONT_PRETTY_PRINT),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче