Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a8459d453b2b90948bcfd1d8620c8a1ceb266eab
      
https://github.com/WebKit/WebKit/commit/a8459d453b2b90948bcfd1d8620c8a1ceb266eab
  Author: Zak Ridouh <[email protected]>
  Date:   2026-07-02 (Thu, 02 Jul 2026)

  Changed paths:
    A 
LayoutTests/http/tests/xsl/resources/xslt-import-delayed-subresource-child.xsl
    A 
LayoutTests/http/tests/xsl/resources/xslt-import-delayed-subresource-grandchild.py
    A 
LayoutTests/http/tests/xsl/resources/xslt-import-delayed-subresource-root.xsl
    A 
LayoutTests/http/tests/xsl/resources/xslt-import-delayed-subresource-target.xml
    A 
LayoutTests/http/tests/xsl/xslt-import-delayed-subresource-crash-expected.txt
    A LayoutTests/http/tests/xsl/xslt-import-delayed-subresource-crash.html
    A 
LayoutTests/platform/glib/http/tests/xsl/xslt-import-delayed-subresource-crash-expected.txt
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/xml/XSLStyleSheetLibxslt.cpp
    M Source/WebCore/xml/XSLTProcessorLibxslt.cpp

  Log Message:
  -----------
  Heap use-after-free of XSLStyleSheet::m_stylesheetDoc after libxslt frees 
imported doc on compile failure
<https://bugs.webkit.org/show_bug.cgi?id=312337>
<rdar://174646751>

Reviewed by David Kilzer and Ryosuke Niwa.

When libxslt fails to compile an imported stylesheet, it frees the
imported doc. The child XSLStyleSheet's m_stylesheetDoc becomes
dangling. If a delayed subresource later arrives and triggers
parseString(), it dereferences the freed pointer

Fix with three layers of defense:

1. Call clearDocuments() on the failure path in transformToString(),
  matching the success path, to null out dangling doc pointers.
2. Skip dict-sharing in parseString() when the parent's doc has been
  handed to libxslt (m_stylesheetDocTaken), since libxslt may have
  freed it.
3. Check isLoading() in applyPendingXSLTransformsTimerFired() to
  avoid compiling partially-loaded import chains in the first place.

* 
LayoutTests/http/tests/xsl/resources/xslt-import-delayed-subresource-child.xsl: 
Added.
* 
LayoutTests/http/tests/xsl/resources/xslt-import-delayed-subresource-grandchild.py:
 Added.
* 
LayoutTests/http/tests/xsl/resources/xslt-import-delayed-subresource-root.xsl: 
Added.
* 
LayoutTests/http/tests/xsl/resources/xslt-import-delayed-subresource-target.xml:
 Added.
* 
LayoutTests/http/tests/xsl/xslt-import-delayed-subresource-crash-expected.txt: 
Added.
* LayoutTests/http/tests/xsl/xslt-import-delayed-subresource-crash.html: Added.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::applyPendingXSLTransformsTimerFired):
* Source/WebCore/xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::parseString):
* Source/WebCore/xml/XSLTProcessorLibxslt.cpp:
(WebCore::XSLTProcessor::transformToString):

Originally-landed-as: 305413.786@safari-7624-branch (3d12363860e5). 
rdar://180438169
Canonical link: https://commits.webkit.org/316377@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to