Bug 70464

Summary: Add a ConstructorMode check to all existing custom V8 constructors
Product: WebKit Reporter: Kentaro Hara <haraken>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, dominicc, japhet, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Kentaro Hara
Reported 2011-10-19 18:18:27 PDT
We should add the following two lines to all existing custom V8 constructors: if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) return args.Holder(); This checks whether a programmer is trying to allocate an object via "new X", or C++ is trying to allocate an object via the function template and wrap the object with a JS flavor. In the latter case, a constructor callback should not be executed (i.e. should return immediately). As for existing custom V8 constructors, no bugs have been occurring without this check for now. However, without the check, the problems that I described in the bug 70015 can happen in the future if someone changes code. In addition, if the check does not exist in existing custom constructors, people will add a new custom constructor without the check without considering the possibility of the problems, which may result in ugly bugs.
Attachments
Patch (13.98 KB, patch)
2011-10-19 18:56 PDT, Kentaro Hara
no flags
Kentaro Hara
Comment 1 2011-10-19 18:56:58 PDT
Adam Barth
Comment 2 2011-10-19 19:00:49 PDT
Comment on attachment 111708 [details] Patch I suspect a bunch of these cases can't actually occur, but I support adding this check everywhere as a model.
WebKit Review Bot
Comment 3 2011-10-19 20:52:11 PDT
Comment on attachment 111708 [details] Patch Clearing flags on attachment: 111708 Committed r97929: <http://trac.webkit.org/changeset/97929>
WebKit Review Bot
Comment 4 2011-10-19 20:52:16 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.