From ee8c51b88395c1c0264adedf1847006e7204d90e Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Wed, 9 Sep 2026 20:26:26 -0700 Subject: [PATCH] XML: retain QuickJS tag sources during copy --- external/qjs_xml_module.c | 4 +++- test/xml/xml.t.mjs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/external/qjs_xml_module.c b/external/qjs_xml_module.c index ae21cedf..67c85859 100644 --- a/external/qjs_xml_module.c +++ b/external/qjs_xml_module.c @@ -869,17 +869,19 @@ qjs_xml_node_tags_modify(JSContext *cx, JSValue obj, njs_str_t *name, } node = qjs_xml_node(cx, v, NULL); - JS_FreeValue(cx, v); if (node == NULL) { + JS_FreeValue(cx, v); goto error; } if (qjs_xml_tree_has_namespaces(node)) { + JS_FreeValue(cx, v); JS_ThrowTypeError(cx, "setval[%u] has namespaces", i); goto error; } node = xmlDocCopyNode(node, current->doc->doc, 1); + JS_FreeValue(cx, v); if (node == NULL) { JS_ThrowInternalError(cx, "xmlDocCopyNode() failed"); goto error; diff --git a/test/xml/xml.t.mjs b/test/xml/xml.t.mjs index db52f0ff..438c736c 100644 --- a/test/xml/xml.t.mjs +++ b/test/xml/xml.t.mjs @@ -592,6 +592,20 @@ let modify_tsuite = { return xml.serializeToString(doc); }, expected: `value` }, + { doc: ``, + skip: () => !has_quickjs(), + get: (doc) => { + let values = []; + + Object.defineProperty(values, '0', { + get: () => xml.parse(`value`), + }); + Object.defineProperty(values, 'length', {value: 1}); + + doc.root.$tags = values; + return xml.serializeToString(doc); + }, + expected: `value` }, { doc: `value`, skip: () => !has_quickjs(), get: (doc) => { -- 2.47.3