diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2025-04-16 17:16:10 +0200 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2025-04-16 17:16:10 +0200 |
commit | db3d3f09cdec7106d6e330aa1eb3fae50ed8fdc4 (patch) | |
tree | 34eaa0d1becbce22da80398f4e920bfdb6faf1db | |
parent | b67c41689ebf4643f8db5b6dcbfafffd945d3e96 (diff) | |
download | quickjs-db3d3f09cdec7106d6e330aa1eb3fae50ed8fdc4.tar.gz quickjs-db3d3f09cdec7106d6e330aa1eb3fae50ed8fdc4.zip |
fixed memory leak in String constructor
-rw-r--r-- | quickjs.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); } |