Bug 226622

Summary: Use references in font loading code instead of pointers which can never be null
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: New BugsAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, clord, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, macpherson, menard, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Myles C. Maxfield 2021-06-03 21:01:11 PDT
Use references instead of pointers which can never be null
Comment 1 Myles C. Maxfield 2021-06-03 22:17:10 PDT
Created attachment 430539 [details]
Patch
Comment 2 Chris Dumez 2021-06-03 22:57:02 PDT
Comment on attachment 430539 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430539&action=review

> Source/WebCore/css/CSSFontFaceSet.cpp:121
> +        Ref<CSSFontFace> face = CSSFontFace::create(*m_owningFontSelector.get(), nullptr, nullptr, true);

.get() should not be needed.

> Source/WebCore/css/FontFaceSet.cpp:169
> +    ASSERT(scriptExecutionContext);

I don't see how this is safe. FontFaceSet is an ActiveDOMObject and an ActiveDOMObject's scriptExecutionContext can definitely become null. I would imagine it is able to hit the assertion by:
1. Having the top frame get a FontFaceSet from a subframe
2. Remove that subframe from the document
3. Have the top frame call load() on that FontFaceSet
Comment 3 Myles C. Maxfield 2021-06-03 23:07:43 PDT
(In reply to Chris Dumez from comment #2)
> Comment on attachment 430539 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=430539&action=review
> 
> > Source/WebCore/css/FontFaceSet.cpp:169
> > +    ASSERT(scriptExecutionContext);
> 
> I don't see how this is safe. FontFaceSet is an ActiveDOMObject and an
> ActiveDOMObject's scriptExecutionContext can definitely become null. I would
> imagine it is able to hit the assertion by:
> 1. Having the top frame get a FontFaceSet from a subframe
> 2. Remove that subframe from the document
> 3. Have the top frame call load() on that FontFaceSet

Aha! You're right. When I was reading ContextDestructionObserver I missed the implementation of the contextDestroyed() function.
Comment 4 Myles C. Maxfield 2021-06-03 23:12:18 PDT
Created attachment 430547 [details]
Patch
Comment 5 Myles C. Maxfield 2021-06-03 23:13:02 PDT
Created attachment 430548 [details]
Patch
Comment 6 Chris Dumez 2021-06-03 23:15:50 PDT
Comment on attachment 430548 [details]
Patch

r=me
Comment 7 EWS 2021-06-04 09:34:22 PDT
Committed r278466 (238486@main): <https://commits.webkit.org/238486@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 430548 [details].
Comment 8 Radar WebKit Bug Importer 2021-06-04 09:35:16 PDT
<rdar://problem/78872787>