]> git.kaiwu.me - njs.git/commitdiff
QuickJS: free joined string with chain pool in qjs_string_create_chb()
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 30 Oct 2026 03:14:34 +0000 (20:14 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 2 Nov 2026 14:42:35 +0000 (06:42 -0800)
Previously, the joined string was freed with the JSContext passed as
the pool argument of the chain free function.  This only worked for
chains initialized with NJS_CHB_CTX_INIT(), where the pool is the
context itself.

Now, the chain pool is used, so the function works with chains using
any allocator.  No functional changes for existing callers.

src/qjs.c

index 78d8f3fdfb15c6720f3fd521bca3a547c0715907..99fdd9442d0853498d6088010a72b881b7ec3513 100644 (file)
--- a/src/qjs.c
+++ b/src/qjs.c
@@ -1350,7 +1350,7 @@ qjs_string_create_chb(JSContext *cx, njs_chb_t *chain)
 
     val = JS_NewStringLen(cx, (const char *) str.start, str.length);
 
-    chain->free(cx, str.start);
+    chain->free(chain->pool, str.start);
 
     return val;
 }