RESOLVED FIXED306787
check-webkit-style: add checker for protect() in variable initialization
https://bugs.webkit.org/show_bug.cgi?id=306787
Summary check-webkit-style: add checker for protect() in variable initialization
David Kilzer (:ddkilzer)
Reported 2026-02-02 10:58:29 PST
The check-webkit-style tool should warn about using `protect()` free function when assigning to RefPtr/Ref variables, which violates SaferCPP guidelines. Bad patterns that should trigger warnings: ```cpp auto foo = protect(m_foo); RefPtr bar = protect(foo()); if (RefPtr client = protect(client())) ``` Good patterns that should NOT trigger warnings: ```cpp protect(foo)->doSomething(); // Method chaining - valid use someFunction(protect(foo)); // Function argument - valid use return protect(m_foo); // Return value - valid use ``` See also: <https://github.com/WebKit/WebKit/wiki/Safer-CPP-Guidelines#do-not-call-protect-free-function-to-initialize-local-variables>
Attachments
Radar WebKit Bug Importer
Comment 1 2026-02-02 10:58:36 PST
David Kilzer (:ddkilzer)
Comment 2 2026-02-02 11:18:25 PST
EWS
Comment 3 2026-02-04 05:26:10 PST
Committed 306771@main (3fa54a20c8ad): <https://commits.webkit.org/306771@main> Reviewed commits have been landed. Closing PR #57712 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.