From 5c668722320eb363f713a0998934aa48fecd56cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 1 Jul 2014 20:00:48 +0200 Subject: Register heap-based JSObject pointers to GC This is necessary so that the GC can move the objects (though I haven't so far encountered this in testing). https://bugs.freedesktop.org/show_bug.cgi?id=69501 --- src/polkitbackend/polkitbackendjsauthority.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/polkitbackend/polkitbackendjsauthority.c b/src/polkitbackend/polkitbackendjsauthority.c index 88f31bd..39f7060 100644 --- a/src/polkitbackend/polkitbackendjsauthority.c +++ b/src/polkitbackend/polkitbackendjsauthority.c @@ -482,6 +482,7 @@ polkit_backend_js_authority_constructed (GObject *object) if (authority->priv->js_global == NULL) goto fail; + JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_global); if (!JS_InitStandardClasses (authority->priv->cx, authority->priv->js_global)) goto fail; @@ -494,6 +495,7 @@ polkit_backend_js_authority_constructed (GObject *object) JSPROP_ENUMERATE); if (authority->priv->js_polkit == NULL) goto fail; + JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_polkit); if (!JS_DefineFunctions (authority->priv->cx, authority->priv->js_polkit, @@ -572,6 +574,11 @@ polkit_backend_js_authority_finalize (GObject *object) g_free (authority->priv->dir_monitors); g_strfreev (authority->priv->rules_dirs); + JS_BeginRequest (authority->priv->cx); + JS_RemoveObjectRoot (authority->priv->cx, &authority->priv->js_polkit); + JS_RemoveObjectRoot (authority->priv->cx, &authority->priv->js_global); + JS_EndRequest (authority->priv->cx); + JS_DestroyContext (authority->priv->cx); JS_DestroyRuntime (authority->priv->rt); /* JS_ShutDown (); */ -- cgit v1.2.1