]> git.kaiwu.me - njs.git/commitdiff
QuickJS: fix fs callback return value leak
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 30 Oct 2026 01:40:09 +0000 (18:40 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 2 Nov 2026 14:42:35 +0000 (06:42 -0800)
Previously, the value returned by a callback passed to the callback
flavor of fs functions was never freed.  The value stayed referenced
until the runtime was freed, triggering the
"list_empty(&rt->gc_obj_list)" assertion in JS_FreeRuntime() in debug
builds and accumulating in the runtime with js_context_reuse.

The issue was introduced in 1f8f9992 (0.8.9).

external/qjs_fs_module.c

index 059b46eb39cc213b9508711768bb697a685a0cb9..42db4ff0b8569a5c200e6039725651a79edf0d22 100644 (file)
@@ -2737,6 +2737,8 @@ qjs_fs_result(JSContext *cx, JSValue result, int calltype, JSValue callback)
             return JS_EXCEPTION;
         }
 
+        JS_FreeValue(cx, promise);
+
         return JS_UNDEFINED;
 
     default: