about summary refs log tree commit diff stats
path: root/lib/quickjs/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2023-12-13 18:59:47 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-14 11:24:33 +0100
commitc842af1bd5e80b40ea83edb040c864aba8c299c6 (patch)
tree102511f3cdbc020e1b17aaca76449a9301616084 /lib/quickjs/quickjs.c
parent71a18c7f8f38f4a6446276f64d2ae9393a6f6207 (diff)
downloadchawan-c842af1bd5e80b40ea83edb040c864aba8c299c6.tar.gz
raise an error if a private method is added twice to an object
Diffstat (limited to 'lib/quickjs/quickjs.c')
-rw-r--r--lib/quickjs/quickjs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 2dbc4914..c68a8ab3 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -7456,6 +7456,12 @@ static int JS_AddBrand(JSContext *ctx, JSValueConst obj, JSValueConst home_obj)
         return -1;
     }
     p1 = JS_VALUE_GET_OBJ(obj);
+    prs = find_own_property(&pr, p1, brand_atom);
+    if (unlikely(prs)) {
+        JS_FreeAtom(ctx, brand_atom);
+        JS_ThrowTypeError(ctx, "private method is already present");
+        return -1;
+    }
     pr = add_property(ctx, p1, brand_atom, JS_PROP_C_W_E);
     JS_FreeAtom(ctx, brand_atom);
     if (!pr)