Skip to content

Commit db3d3f0

Browse files
author
Fabrice Bellard
committed
fixed memory leak in String constructor
1 parent b67c416 commit db3d3f0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

quickjs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41422,7 +41422,9 @@ static JSValue js_string_constructor(JSContext *ctx, JSValueConst new_target,
4142241422
JSString *p1 = JS_VALUE_GET_STRING(val);
4142341423

4142441424
obj = js_create_from_ctor(ctx, new_target, JS_CLASS_STRING);
41425-
if (!JS_IsException(obj)) {
41425+
if (JS_IsException(obj)) {
41426+
JS_FreeValue(ctx, val);
41427+
} else {
4142641428
JS_SetObjectData(ctx, obj, val);
4142741429
JS_DefinePropertyValue(ctx, obj, JS_ATOM_length, JS_NewInt32(ctx, p1->len), 0);
4142841430
}

0 commit comments

Comments
 (0)