From: Fabrice Bellard Date: Wed, 16 Apr 2025 15:16:10 +0000 (+0200) Subject: fixed memory leak in String constructor X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/stylesheets/stylesheet.css?a=commitdiff_plain;h=db3d3f09cdec7106d6e330aa1eb3fae50ed8fdc4;p=quickjs.git fixed memory leak in String constructor --- diff --git a/quickjs.c b/quickjs.c index 01988b4..8b0b04f 100644 --- a/quickjs.c +++ b/quickjs.c @@ -41422,7 +41422,9 @@ static JSValue js_string_constructor(JSContext *ctx, JSValueConst new_target, JSString *p1 = JS_VALUE_GET_STRING(val); obj = js_create_from_ctor(ctx, new_target, JS_CLASS_STRING); - if (!JS_IsException(obj)) { + if (JS_IsException(obj)) { + JS_FreeValue(ctx, val); + } else { JS_SetObjectData(ctx, obj, val); JS_DefinePropertyValue(ctx, obj, JS_ATOM_length, JS_NewInt32(ctx, p1->len), 0); }