From: Fabrice Bellard Date: Sat, 28 Nov 2026 10:00:28 +0000 (+0100) Subject: removed memory leak and fixes Object.isFrozen/isSealed (#631) X-Git-Url: https://git.kaiwu.me/web/%7B@url%7D?a=commitdiff_plain;h=4133ff406a35253c57336b59f44785a4c9f3c45a;p=quickjs.git removed memory leak and fixes Object.isFrozen/isSealed (#631) --- diff --git a/quickjs.c b/quickjs.c index 498ac39..d2be049 100644 --- a/quickjs.c +++ b/quickjs.c @@ -42143,10 +42143,17 @@ static JSValue js_object_isSealed(JSContext *ctx, JSValueConst this_val, JSPropertyEnum *props; uint32_t len, i; int flags, res; - + JSValue ret; + if (!JS_IsObject(obj)) return JS_TRUE; + res = JS_IsExtensible(ctx, obj); + if (res < 0) + return JS_EXCEPTION; + if (res) + return JS_FALSE; + p = JS_VALUE_GET_OBJ(obj); flags = JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK; if (JS_GetOwnPropertyNamesInternal(ctx, &props, &len, p, flags)) @@ -42157,28 +42164,23 @@ static JSValue js_object_isSealed(JSContext *ctx, JSValueConst this_val, JSAtom prop = props[i].atom; res = JS_GetOwnPropertyInternal(ctx, &desc, p, prop); - if (res < 0) - goto exception; + if (res < 0) { + ret = JS_EXCEPTION; + goto done; + } if (res) { js_free_desc(ctx, &desc); if ((desc.flags & JS_PROP_CONFIGURABLE) || (is_frozen && (desc.flags & JS_PROP_WRITABLE))) { - res = FALSE; + ret = JS_FALSE; goto done; } } } - res = JS_IsExtensible(ctx, obj); - if (res < 0) - return JS_EXCEPTION; - res ^= 1; + ret = JS_TRUE; done: JS_FreePropertyEnum(ctx, props, len); - return JS_NewBool(ctx, res); - -exception: - JS_FreePropertyEnum(ctx, props, len); - return JS_EXCEPTION; + return ret; } static JSValue js_object_fromEntries(JSContext *ctx, JSValueConst this_val,