mirror of
https://github.com/bellard/quickjs.git
synced 2025-09-29 14:36:30 +03:00
raise an error if a private method is added twice to an object
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user