From 57695ee20213aa6516a112f39a9955a87f4284c7 Mon Sep 17 00:00:00 2001 From: engsr6982 Date: Wed, 15 Apr 2026 00:20:28 +0800 Subject: [PATCH] Fix atom leak in JS_NewSymbol --- quickjs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index 3bf342e31..db5d04135 100644 --- a/quickjs.c +++ b/quickjs.c @@ -3415,7 +3415,9 @@ JSValue JS_NewSymbol(JSContext *ctx, const char *description, bool is_global) JSAtom atom = JS_NewAtom(ctx, description); if (atom == JS_ATOM_NULL) return JS_EXCEPTION; - return JS_NewSymbolFromAtom(ctx, atom, is_global ? JS_ATOM_TYPE_GLOBAL_SYMBOL : JS_ATOM_TYPE_SYMBOL); + JSValue symbol = JS_NewSymbolFromAtom(ctx, atom, is_global ? JS_ATOM_TYPE_GLOBAL_SYMBOL : JS_ATOM_TYPE_SYMBOL); + JS_FreeAtom(ctx, atom); + return symbol; } #define ATOM_GET_STR_BUF_SIZE 64