mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 869479 - GC: Fix rooting hazards in jsapi tests r=terrence
This commit is contained in:
parent
1bbfb14e1e
commit
c95ca87137
@ -38,7 +38,7 @@ CompileScriptForPrincipalsVersionOrigin(JSContext *cx, JS::HandleObject obj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSScript *
|
JSScript *
|
||||||
FreezeThaw(JSContext *cx, JSScript *script)
|
FreezeThaw(JSContext *cx, JS::HandleScript script)
|
||||||
{
|
{
|
||||||
// freeze
|
// freeze
|
||||||
uint32_t nbytes;
|
uint32_t nbytes;
|
||||||
@ -47,9 +47,10 @@ FreezeThaw(JSContext *cx, JSScript *script)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// thaw
|
// thaw
|
||||||
script = JS_DecodeScript(cx, memory, nbytes, script->principals(), script->originPrincipals);
|
JSScript *script2 = JS_DecodeScript(cx, memory, nbytes,
|
||||||
|
script->principals(), script->originPrincipals);
|
||||||
js_free(memory);
|
js_free(memory);
|
||||||
return script;
|
return script2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSScript *
|
static JSScript *
|
||||||
@ -123,9 +124,9 @@ JSScript *createScriptViaXDR(JSPrincipals *prin, JSPrincipals *orig, int testCas
|
|||||||
"f;\n";
|
"f;\n";
|
||||||
|
|
||||||
JS::RootedObject global(cx, JS_GetGlobalObject(cx));
|
JS::RootedObject global(cx, JS_GetGlobalObject(cx));
|
||||||
JSScript *script = CompileScriptForPrincipalsVersionOrigin(cx, global, prin, orig,
|
JS::RootedScript script(cx, CompileScriptForPrincipalsVersionOrigin(cx, global, prin, orig,
|
||||||
src, strlen(src), "test", 1,
|
src, strlen(src), "test", 1,
|
||||||
JSVERSION_DEFAULT);
|
JSVERSION_DEFAULT));
|
||||||
if (!script)
|
if (!script)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ BEGIN_TEST(testXDR_bug506491)
|
|||||||
"var f = makeClosure('0;', 'status', 'ok');\n";
|
"var f = makeClosure('0;', 'status', 'ok');\n";
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
JSScript *script = JS_CompileScript(cx, global, s, strlen(s), __FILE__, __LINE__);
|
JS::RootedScript script(cx, JS_CompileScript(cx, global, s, strlen(s), __FILE__, __LINE__));
|
||||||
CHECK(script);
|
CHECK(script);
|
||||||
|
|
||||||
script = FreezeThaw(cx, script);
|
script = FreezeThaw(cx, script);
|
||||||
@ -187,7 +188,7 @@ END_TEST(testXDR_bug506491)
|
|||||||
BEGIN_TEST(testXDR_bug516827)
|
BEGIN_TEST(testXDR_bug516827)
|
||||||
{
|
{
|
||||||
// compile an empty script
|
// compile an empty script
|
||||||
JSScript *script = JS_CompileScript(cx, global, "", 0, __FILE__, __LINE__);
|
JS::RootedScript script(cx, JS_CompileScript(cx, global, "", 0, __FILE__, __LINE__));
|
||||||
CHECK(script);
|
CHECK(script);
|
||||||
|
|
||||||
script = FreezeThaw(cx, script);
|
script = FreezeThaw(cx, script);
|
||||||
@ -208,7 +209,7 @@ BEGIN_TEST(testXDR_source)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
for (const char **s = samples; *s; s++) {
|
for (const char **s = samples; *s; s++) {
|
||||||
JSScript *script = JS_CompileScript(cx, global, *s, strlen(*s), __FILE__, __LINE__);
|
JS::RootedScript script(cx, JS_CompileScript(cx, global, *s, strlen(*s), __FILE__, __LINE__));
|
||||||
CHECK(script);
|
CHECK(script);
|
||||||
script = FreezeThaw(cx, script);
|
script = FreezeThaw(cx, script);
|
||||||
CHECK(script);
|
CHECK(script);
|
||||||
|
Loading…
Reference in New Issue
Block a user