summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2024-03-24 15:21:59 +0100
committerRafael Marçalo <raroma09@gmail.com>2024-06-10 21:13:55 +0100
commit12a8a549a0e1d54f6f7ee60ae24e597236feb240 (patch)
tree3ffb81eb049a2f21a1b25f018787c8e0f8fe3809
parentdf74f11b65c2414d938d7781e5dc6a69e52394d0 (diff)
webext: Free JavaScript objects
Webkit documentation says JavaScript objects refcount is always increased, and has to be released always.
-rw-r--r--webext-surf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/webext-surf.c b/webext-surf.c
index 84191f3..230c71b 100644
--- a/webext-surf.c
+++ b/webext-surf.c
@@ -25,6 +25,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
static char js[48], msg[MSGBUFSZ];
WebKitWebPage *page;
JSCContext *jsc;
+ JSCValue *jsv;
GError *gerr = NULL;
gsize msgsz;
@@ -48,6 +49,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
return TRUE;
jsc = webkit_frame_get_js_context(webkit_web_page_get_main_frame(page));
+ jsv = NULL;
switch (msg[1]) {
case 'h':
@@ -56,7 +58,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
snprintf(js, sizeof(js),
"window.scrollBy(window.innerWidth/100*%hhd,0);",
msg[2]);
- jsc_context_evaluate(jsc, js, -1);
+ jsv = jsc_context_evaluate(jsc, js, -1);
break;
case 'v':
if (msgsz != 3)
@@ -64,10 +66,14 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
snprintf(js, sizeof(js),
"window.scrollBy(0,window.innerHeight/100*%hhd);",
msg[2]);
- jsc_context_evaluate(jsc, js, -1);
+ jsv = jsc_context_evaluate(jsc, js, -1);
break;
}
+ g_object_unref(jsc);
+ if (jsv)
+ g_object_unref(jsv);
+
return TRUE;
}