Changeset 38115 in webkit


Ignore:
Timestamp:
Nov 4, 2008 4:24:44 PM (15 years ago)
Author:
pam@chromium.org
Message:

2008-11-04 Jonathan Haas <myrdred@gmail.com>

Addiitonal tweaks and patch prep by Pamela Greene <pam@chromium.org>

Reviewed by Darin Adler.

Fixed an issue which could cause memory corruption using ToT libxml.
See https://bugs.webkit.org/show_bug.cgi?id=15715

Test: fast/xsl/xslt-nested-stylesheets.xml

  • xml/XSLImportRule.cpp: (WebCore::XSLImportRule::setXSLStyleSheet): Set parent rather than owner document
  • xml/XSLStyleSheet.cpp: (WebCore::XSLStyleSheet::XSLStyleSheet): Initialize m_parentStyleSheet (WebCore::XSLStyleSheet::parseString): Make all child stylesheets use parent's dictionary (WebCore::XSLStyleSheet::setParentStyleSheet): Added
  • xml/XSLStyleSheet.h: Added m_parentStyleSheet member

2008-11-04 Pamela Greene <pam@chromium.org>

Reviewed by Darin Adler.

Added test for crash resulting from nested stylesheets using certain
builds of libxml2. See https://bugs.webkit.org/show_bug.cgi?id=15715 .

  • fast/xsl/resources/xslt-nested-stylesheets0.xsl: Added.
  • fast/xsl/resources/xslt-nested-stylesheets1.xsl: Added.
  • fast/xsl/xslt-nested-stylesheets-expected.txt: Added.
  • fast/xsl/xslt-nested-stylesheets.xml: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r38103 r38115  
     12008-11-04  Pamela Greene  <pam@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Added test for crash resulting from nested stylesheets using certain
     6        builds of libxml2.  See https://bugs.webkit.org/show_bug.cgi?id=15715 .
     7
     8        * fast/xsl/resources/xslt-nested-stylesheets0.xsl: Added.
     9        * fast/xsl/resources/xslt-nested-stylesheets1.xsl: Added.
     10        * fast/xsl/xslt-nested-stylesheets-expected.txt: Added.
     11        * fast/xsl/xslt-nested-stylesheets.xml: Added.
     12
    1132008-11-04  Pierre-Olivier Latour  <pol@apple.com>
    214
  • trunk/WebCore/ChangeLog

    r38112 r38115  
     12008-11-04  Jonathan Haas  <myrdred@gmail.com>
     2
     3        Addiitonal tweaks and patch prep by Pamela Greene <pam@chromium.org>
     4
     5        Reviewed by Darin Adler.
     6
     7        Fixed an issue which could cause memory corruption using ToT libxml.
     8        See https://bugs.webkit.org/show_bug.cgi?id=15715
     9
     10        Test: fast/xsl/xslt-nested-stylesheets.xml
     11
     12        * xml/XSLImportRule.cpp:
     13        (WebCore::XSLImportRule::setXSLStyleSheet): Set parent rather than owner document
     14        * xml/XSLStyleSheet.cpp:
     15        (WebCore::XSLStyleSheet::XSLStyleSheet): Initialize m_parentStyleSheet
     16        (WebCore::XSLStyleSheet::parseString): Make all child stylesheets use parent's dictionary
     17        (WebCore::XSLStyleSheet::setParentStyleSheet): Added
     18        * xml/XSLStyleSheet.h: Added m_parentStyleSheet member
     19
    1202008-11-04  Simon Fraser  <simon.fraser@apple.com>
    221
  • trunk/WebCore/xml/XSLImportRule.cpp

    r34627 r38115  
    6262    XSLStyleSheet* parent = parentStyleSheet();
    6363    if (parent)
    64         m_styleSheet->setOwnerDocument(parent->ownerDocument());
     64        m_styleSheet->setParentStyleSheet(parent);
    6565
    6666    m_styleSheet->parseString(sheet);
  • trunk/WebCore/xml/XSLStyleSheet.cpp

    r34627 r38115  
    6161    , m_processed(false) // Child sheets get marked as processed when the libxslt engine has finally seen them.
    6262    , m_stylesheetDocTaken(false)
     63    , m_parentStyleSheet(0)
    6364{
    6465}
     
    7172    , m_processed(true) // The root sheet starts off processed.
    7273    , m_stylesheetDocTaken(false)
     74    , m_parentStyleSheet(0)
    7375{
    7476}
     
    148150    xmlSetGenericErrorFunc(console, XSLTProcessor::genericErrorFunc);
    149151
    150     m_stylesheetDoc = xmlReadMemory(reinterpret_cast<const char*>(string.characters()), string.length() * sizeof(UChar),
     152    const char* buffer = reinterpret_cast<const char*>(string.characters());
     153    int size = string.length() * sizeof(UChar);
     154
     155    xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(buffer, size);
     156
     157    if (m_parentStyleSheet) {
     158        // The XSL transform may leave the newly-transformed document
     159        // with references to the symbol dictionaries of the style sheet
     160        // and any of its children. XML document disposal can corrupt memory
     161        // if a document uses more than one symbol dictionary, so we
     162        // ensure that all child stylesheets use the same dictionaries as their
     163        // parents.
     164        xmlDictFree(ctxt->dict);
     165        ctxt->dict = m_parentStyleSheet->m_stylesheetDoc->dict;
     166        xmlDictReference(ctxt->dict);
     167    }
     168
     169    m_stylesheetDoc = xmlCtxtReadMemory(ctxt, buffer, size,
    151170        href().utf8().data(),
    152171        BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE",
     
    234253        m_stylesheetDocTaken = true;
    235254    return result;
     255}
     256
     257void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet* parent)
     258{
     259    m_parentStyleSheet = parent;
     260    if (parent)
     261        m_ownerDocument = parent->ownerDocument();
    236262}
    237263
  • trunk/WebCore/xml/XSLStyleSheet.h

    r34627 r38115  
    7171
    7272    Document* ownerDocument() { return m_ownerDocument; }
    73     void setOwnerDocument(Document* doc) { m_ownerDocument = doc; }
     73    void setParentStyleSheet(XSLStyleSheet* parent);
    7474
    7575    xmlDocPtr document();
     
    9191    bool m_processed;
    9292    bool m_stylesheetDocTaken;
     93    XSLStyleSheet* m_parentStyleSheet;
    9394};
    9495
Note: See TracChangeset for help on using the changeset viewer.