From 3ba50e85747d31deaa2c4c17950b46fc50019564 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 5 May 2019 18:51:41 +0100 Subject: [PATCH] Force a GC to ensure old compartment goes away Signed-off-by: Daniel Silverstone --- content/handlers/javascript/duktape/dukky.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c index 2755a272f..8af3165b6 100644 --- a/content/handlers/javascript/duktape/dukky.c +++ b/content/handlers/javascript/duktape/dukky.c @@ -611,7 +611,11 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv) NSLOG(dukky, DEBUG, "New javascript/duktape compartment, win_priv=%p, doc_priv=%p", win_priv, doc_priv); - duk_set_top(ctx->ctx, 0); + if (CTX != NULL) { + duk_set_top(ctx->ctx, 0); + duk_gc(ctx->ctx, 0); + duk_gc(ctx->ctx, DUK_GC_COMPACT); + } duk_push_thread(ctx->ctx); ctx->thread = duk_require_context(ctx->ctx, -1); duk_push_int(CTX, 0);