summaryrefslogtreecommitdiff
path: root/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2023-12-13 18:59:47 +0100
committerFabrice Bellard <fabrice@bellard.org>2023-12-13 18:59:47 +0100
commit9e529652572e704d420e6b678f1601b720aae2d7 (patch)
tree55fb618497459d93d9931f045e40416479cd072e /quickjs.c
parentdaa35bc1e5d43192098af9b51caeb4f18f73f9f9 (diff)
downloadquickjs-9e529652572e704d420e6b678f1601b720aae2d7.tar.gz
quickjs-9e529652572e704d420e6b678f1601b720aae2d7.zip
raise an error if a private method is added twice to an object
Diffstat (limited to 'quickjs.c')
-rw-r--r--quickjs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/quickjs.c b/quickjs.c
index 4c4d273..58c638a 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -7336,6 +7336,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)