Skip to content

Commit

Permalink
Cherry-pick 6d542b7. rdar://123016231
Browse files Browse the repository at this point in the history
    AX: AccessibilitySVGElement::description() is missing several null-checks, causing crashes
    https://bugs.webkit.org/show_bug.cgi?id=269530
    rdar://123016231

    Reviewed by Chris Fleizach.

    * Source/WebCore/accessibility/AccessibilitySVGElement.cpp:
    (WebCore::AccessibilitySVGElement::description const):

    Canonical link: https://commits.webkit.org/274934@main

Identifier: 272448.786@safari-7618-branch
  • Loading branch information
twilco authored and Dan Robson committed Mar 26, 2024
1 parent b9ef776 commit 4449643
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Source/WebCore/accessibility/AccessibilitySVGElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,29 @@ String AccessibilitySVGElement::description() const
if (!ariaDescription.isEmpty())
return ariaDescription;

auto titleElements = childrenOfType<SVGTitleElement>(*element());
if (auto titleChild = childElementWithMatchingLanguage(titleElements))
return titleChild->textContent();
RefPtr element = this->element();
if (element) {
auto titleElements = childrenOfType<SVGTitleElement>(*element);
if (auto* titleChild = childElementWithMatchingLanguage(titleElements))
return titleChild->textContent();
}

if (is<SVGAElement>(element())) {
auto& xlinkTitle = element()->attributeWithoutSynchronization(XLinkNames::titleAttr);
if (is<SVGAElement>(element.get())) {
const auto& xlinkTitle = element->attributeWithoutSynchronization(XLinkNames::titleAttr);
if (!xlinkTitle.isEmpty())
return xlinkTitle;
}

if (is<SVGUseElement>(element())) {
if (is<SVGUseElement>(element.get())) {
if (auto* target = targetForUseElement())
return target->description();
}

// FIXME: This is here to not break the svg-image.html test. But 'alt' is not
// listed as a supported attribute of the 'image' element in the SVG spec:
// https://www.w3.org/TR/SVG/struct.html#ImageElement
if (m_renderer->isRenderOrLegacyRenderSVGImage()) {
const AtomString& alt = getAttribute(HTMLNames::altAttr);
if (m_renderer && m_renderer->isRenderOrLegacyRenderSVGImage()) {
const auto& alt = getAttribute(HTMLNames::altAttr);
if (!alt.isNull())
return alt;
}
Expand Down

0 comments on commit 4449643

Please sign in to comment.