Bug 248699 - AX: Add missing null checks to prevent crashes when accessing SVG elements
Summary: AX: Add missing null checks to prevent crashes when accessing SVG elements
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-12-02 17:38 PST by Tyler Wilcock
Modified: 2022-12-04 12:29 PST (History)
10 users (show)

See Also:


Attachments
Patch (7.68 KB, patch)
2022-12-02 18:14 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (7.64 KB, patch)
2022-12-03 11:24 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Wilcock 2022-12-02 17:38:37 PST
AX: Add missing null checks to prevent crashes when accessing SVG elements
Comment 1 Radar WebKit Bug Importer 2022-12-02 17:38:48 PST
<rdar://problem/102924620>
Comment 2 Tyler Wilcock 2022-12-02 18:14:45 PST
Created attachment 463864 [details]
Patch
Comment 3 Andres Gonzalez 2022-12-03 10:02:34 PST
(In reply to Tyler Wilcock from comment #2)
> Created attachment 463864 [details]
> Patch

--- a/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
+++ b/Source/WebCore/accessibility/AccessibilityNodeObject.cpp

+    if (focusedElement == m_node || isFocusedWebArea())
         return true;

     return false;

While at it, can you replace the above 4 lines with:

    return focusedElement == m_node || isFocusedWebArea();


Looks good. Thanks!
Comment 4 Andres Gonzalez 2022-12-03 10:13:51 PST
(In reply to Tyler Wilcock from comment #2)
> Created attachment 463864 [details]
> Patch

--- a/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
+++ b/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
@@ -2428,10 +2428,17 @@ bool AccessibilityNodeObject::isFocused() const

it may be even better to return early in:

    auto* focusedElement = document.focusedElement();
    if (!focusedElement)
        return false;

    if (focusedElement == m_node)
        return true;

and then do the web area stuff.
Comment 5 Tyler Wilcock 2022-12-03 11:24:00 PST
Created attachment 463869 [details]
Patch
Comment 6 Tyler Wilcock 2022-12-04 11:47:25 PST
rdar://102843966
Comment 7 EWS 2022-12-04 12:29:49 PST
Committed 257359@main (cdd13301fca6): <https://commits.webkit.org/257359@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 463869 [details].