]> git.kaiwu.me - quickjs.git/commitdiff
Drop the new prototype's reference when the shape cannot be made writable
authorFabrice Bellard <fabrice@bellard.org>
Sat, 21 Nov 2026 13:49:09 +0000 (14:49 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Sat, 21 Nov 2026 13:49:09 +0000 (14:49 +0100)
quickjs.c

index fabeac6a1156bc30d453dcd34e59d726f9808f2b..feec990b702b2880455c9fe90474454b57d9972c 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -8112,8 +8112,11 @@ static int JS_SetPrototypeInternal(JSContext *ctx, JSValueConst obj,
         JS_DupValue(ctx, proto_val);
     }
 
-    if (js_shape_prepare_update(ctx, p, NULL))
+    if (js_shape_prepare_update(ctx, p, NULL)) {
+        if (proto)
+            JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, proto));
         return -1;
+    }
     sh = p->shape;
     if (sh->proto)
         JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, sh->proto));