diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2023-12-13 18:59:47 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-14 11:24:33 +0100 |
commit | c842af1bd5e80b40ea83edb040c864aba8c299c6 (patch) | |
tree | 102511f3cdbc020e1b17aaca76449a9301616084 /lib/quickjs/quickjs.c | |
parent | 71a18c7f8f38f4a6446276f64d2ae9393a6f6207 (diff) | |
download | chawan-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.c | 6 |
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) |