]> git.kaiwu.me - njs.git/commit
Fixed allocator mismatch in drain/drop.
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 21 Apr 2026 01:47:05 +0000 (18:47 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 18 May 2026 15:34:20 +0000 (08:34 -0700)
commit5cd5ebf592e4ff39336a218ac5206f913adebde1
tree1b4e32df808634fbf6e3ae5fe85f6b35b2da59da
parentf6afbf3733766a2a224d3cd9867afdc0f7179721
Fixed allocator mismatch in drain/drop.

njs_chb_destroy() frees chain nodes through chain->free() and guards
against a NULL free callback.  njs_chb_drain() and the tail-freeing
path of njs_chb_drop() called njs_mp_free() directly, which is wrong
for chains initialized with NJS_CHB_CTX_INIT() where chain->free is
js_free(), and unsafe for NGX_CHB_CTX_INIT() chains where chain->free
is NULL.

Both paths now route through chain->free() with the same NULL guard
as njs_chb_destroy().
src/njs_chb.c