diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2023-12-13 18:59:47 +0100 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2023-12-13 18:59:47 +0100 |
commit | 9e529652572e704d420e6b678f1601b720aae2d7 (patch) | |
tree | 55fb618497459d93d9931f045e40416479cd072e /quickjs.c | |
parent | daa35bc1e5d43192098af9b51caeb4f18f73f9f9 (diff) | |
download | quickjs-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.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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) |