RESOLVED FIXED306244
Fix -Wlifetime-safety-permissive warning in FontRanges::glyphDataForCharacter()
https://bugs.webkit.org/show_bug.cgi?id=306244
Summary Fix -Wlifetime-safety-permissive warning in FontRanges::glyphDataForCharacter()
David Kilzer (:ddkilzer)
Reported 2026-01-25 19:50:49 PST
Clang's lifetime safety warning detected a potential issue in FontRanges::glyphDataForCharacter(): ``` OpenSource/Source/WebCore/platform/graphics/FontRanges.cpp:94:38: error: object whose reference is captured may not live long enough [-Werror,-Wlifetime-safety-strict] 94 | resultFont = font.get(); | ^~~~ OpenSource/Source/WebCore/platform/graphics/FontRanges.cpp:104:13: note: destroyed here 104 | } | ^ OpenSource/Source/WebCore/platform/graphics/FontRanges.cpp:93:26: note: later used here 93 | if (\!resultFont) | ^~~~~~~~~~ ``` Even though the code was safe (the Font is kept alive by the FontAccessor), the analyzer couldn't prove the lifetime relationship.
Attachments
David Kilzer (:ddkilzer)
Comment 1 2026-01-25 19:50:51 PST
The fix changes `resultFont` from `const Font*` to `RefPtr<const Font>` to make the lifetime relationship explicit and eliminate the warning. Also uses `WTF::move(font)` to avoid ref count churn since `font` isn't used after that point in the `isInterstitial()` branch. No change in behavior, only compiler warning elimination.
Radar WebKit Bug Importer
Comment 2 2026-01-25 19:50:55 PST
Radar WebKit Bug Importer
Comment 3 2026-01-25 19:50:56 PST
David Kilzer (:ddkilzer)
Comment 4 2026-01-25 20:15:34 PST
EWS
Comment 5 2026-01-26 13:51:27 PST
Committed 306238@main (3118028cc9ac): <https://commits.webkit.org/306238@main> Reviewed commits have been landed. Closing PR #57231 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.