RESOLVED FIXED279339
CanMakeCheckedPtrBase::operator== should only be used by subclass' defaulted overload
https://bugs.webkit.org/show_bug.cgi?id=279339
Summary CanMakeCheckedPtrBase::operator== should only be used by subclass' defaulted ...
Gerald Squelart
Reported 2024-09-08 22:05:57 PDT
`CanMakeCheckedPtrBase::operator==` just returns true, so that a subclass can defaults its operator==, and that default will effectively not consider the base CanMakeCheckedPtrBase when comparing base&member data. This creates a possible foot-gun, where a sub-class doesn't define any operator==, so comparing objects will directly call `CanMakeCheckedPtrBase::operator==` and always compare equal! This was the case for a comparison of Node's, which bug 279330 fixed. It would be best to prevent this class of issues in the future. This will be done by adding an opt-in template parameter to CanMakeCheckedPtr and CanMakeThreadSafeCheckedPtr, such that either: - A derived class that defaults its operator== can safely use CanMakeCheckedPtrBase::operator==, or - Other derived classes (that don't provide their own operator==) will not incorrectly compare equal in all cases.
Attachments
Radar WebKit Bug Importer
Comment 1 2024-09-08 22:06:06 PDT
Gerald Squelart
Comment 2 2024-09-08 22:12:42 PDT
EWS
Comment 3 2024-09-09 08:00:04 PDT
Committed 283341@main (dd2152442c41): <https://commits.webkit.org/283341@main> Reviewed commits have been landed. Closing PR #33306 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.