]> git.kaiwu.me - njs.git/commit
QuickJS: fix consumed value cleanup
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 3 Jun 2026 05:11:58 +0000 (22:11 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 5 Jun 2026 16:03:58 +0000 (09:03 -0700)
commitd9c97cf9a13e7a26206345b774fcfe609fbe4ef3
tree697c54ec0a36c41cc6ef1524b09a04c36258eb2c
parent0bdc82115c1020281e98fd6b00395ea8b7c837fe
QuickJS: fix consumed value cleanup

QuickJS property setter and define APIs consume the JSValue argument on
both success and failure.  This applies to JS_SetProperty(),
JS_SetPropertyStr(), JS_SetPropertyUint32(), JS_DefinePropertyValue(),
JS_DefinePropertyValueStr(), and JS_DefinePropertyValueUint32().

Do not free values after passing them to these APIs, including failure
paths in shared cleanup labels.  Target objects and containers are not
consumed by these calls and still need normal cleanup unless ownership
has been transferred by inserting them into another object.

Also fix adjacent cleanup paths that leaked target objects after a
setter consumed the value being attached.

Reported by R4mbb of KRsecurity.
external/qjs_fs_module.c
external/qjs_query_string_module.c
external/qjs_webcrypto_module.c
external/qjs_xml_module.c
nginx/ngx_http_js_module.c
nginx/ngx_js_shared_dict.c
nginx/ngx_qjs_fetch.c
src/qjs.c