From d2fd8adaba13fbeaff31d9f55c0923cd8392e630 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Fri, 26 Sep 2025 14:11:29 -0400 Subject: [PATCH 1/2] removed module leak in js_std_eval_binary() Port of bellard/quickjs@1fdc768fdc8571300755cdd3e4654ce99c0255ce Co-authored-by: Fabrice Bellard --- quickjs-libc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/quickjs-libc.c b/quickjs-libc.c index 7485001eb..c1d3f804f 100644 --- a/quickjs-libc.c +++ b/quickjs-libc.c @@ -4586,6 +4586,7 @@ void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len, if (js_module_set_import_meta(ctx, obj, false, false) < 0) goto exception; } + JS_FreeValue(ctx, obj); } else { if (JS_VALUE_GET_TAG(obj) == JS_TAG_MODULE) { if (JS_ResolveModule(ctx, obj) < 0) { From 9771f5d8656ec959067c838e1adac3afd1b802e0 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Fri, 26 Sep 2025 14:37:32 -0400 Subject: [PATCH 2/2] removed js_array_every() memory leak Cherry-pick of bellard/quickjs@de4d3927b8edff5fbfee1f69cfeef840844259e9 Co-authored-by: Fabrice Bellard --- quickjs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index f63b7df66..60d33cf8f 100644 --- a/quickjs.c +++ b/quickjs.c @@ -39934,8 +39934,10 @@ static JSValue js_array_every(JSContext *ctx, JSValueConst this_val, goto exception; args[0] = ret; res = JS_Invoke(ctx, arr, JS_ATOM_set, 1, args); - if (check_exception_free(ctx, res)) + if (check_exception_free(ctx, res)) { + JS_FreeValue(ctx, arr); goto exception; + } JS_FreeValue(ctx, ret); ret = arr; }