Bug 306244
| Summary: | Fix -Wlifetime-safety-permissive warning in FontRanges::glyphDataForCharacter() | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | David Kilzer (:ddkilzer) <ddkilzer> |
| Component: | Text | Assignee: | David Kilzer (:ddkilzer) <ddkilzer> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | fantasai.bugs, vitor.roriz, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=306226 | ||
David Kilzer (:ddkilzer)
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
David Kilzer (:ddkilzer)
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
<rdar://problem/168892583>
Radar WebKit Bug Importer
<rdar://problem/168892499>
David Kilzer (:ddkilzer)
Pull request: https://github.com/WebKit/WebKit/pull/57231
EWS
Committed 306238@main (3118028cc9ac): <https://commits.webkit.org/306238@main>
Reviewed commits have been landed. Closing PR #57231 and removing active labels.