From 8b006749e9ade35ce3948826e45a7439d0528340 Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 2 Nov 2026 00:38:52 +0100 Subject: [PATCH] Fix symbol leak in JS_ValueToAtom JS_DupAtom behaves differently for symbols than JS_DupValue, so that a built-in symbol gets dup'd as a value but not as an atom. So this must be accounted for here. --- quickjs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index a824b57156..9aa175114e 100644 --- a/quickjs.c +++ b/quickjs.c @@ -9169,7 +9169,8 @@ JSAtom JS_ValueToAtom(JSContext *ctx, JSValueConst val) if (JS_IsException(str)) return JS_ATOM_NULL; if (JS_VALUE_GET_TAG(str) == JS_TAG_SYMBOL) { - atom = js_symbol_to_atom(ctx, str); + atom = JS_DupAtom(ctx, js_symbol_to_atom(ctx, str)); + JS_FreeValue(ctx, str); } else { atom = JS_NewAtomStr(ctx, JS_VALUE_GET_STRING(str)); }