Commit bf437b45 authored by eseidel's avatar eseidel

Bug #: 6101

Submitted by: eseidel
Reviewed by: mjs
        Leaks in XSLTProcessorImpl due to early exit in failure case
        http://bugzilla.opendarwin.org/show_bug.cgi?id=6101

        * khtml/xsl/xslt_processorimpl.cpp:
        (DOM::xmlDocPtrFromNode): add "shouldDelete" argument
        (DOM::XSLTProcessorImpl::transformToString): delete new'd xmlDoc


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11820 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6b709be4
......@@ -8,6 +8,17 @@
* kwq/WebCoreBridge.h: Removed childFrames method from WebCoreBridge protocol
since it is not actually used.
2005-12-29 Eric Seidel <eseidel@apple.com>
Reviewed by mjs.
Leaks in XSLTProcessorImpl due to early exit in failure case
http://bugzilla.opendarwin.org/show_bug.cgi?id=6101
* khtml/xsl/xslt_processorimpl.cpp:
(DOM::xmlDocPtrFromNode): add "shouldDelete" argument
(DOM::XSLTProcessorImpl::transformToString): delete new'd xmlDoc
2005-12-29 Eric Seidel <eseidel@apple.com>
File accidentally omitted from previous commit.
......
......@@ -257,7 +257,7 @@ static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheetImpl> &cached
return cachedStylesheet->compileStyleSheet();
}
static inline xmlDocPtr xmlDocPtrFromNode(NodeImpl *sourceNode)
static inline xmlDocPtr xmlDocPtrFromNode(NodeImpl *sourceNode, bool &shouldDelete)
{
RefPtr<DocumentImpl> ownerDocument = sourceNode->getDocument();
bool sourceIsDocument = (sourceNode == ownerDocument.get());
......@@ -265,8 +265,10 @@ static inline xmlDocPtr xmlDocPtrFromNode(NodeImpl *sourceNode)
xmlDocPtr sourceDoc = 0;
if (sourceIsDocument)
sourceDoc = (xmlDocPtr)ownerDocument->transformSource();
if (!sourceDoc)
if (!sourceDoc) {
sourceDoc = (xmlDocPtr)xmlDocPtrForString(createMarkup(sourceNode), sourceIsDocument ? ownerDocument->URL() : QString());
shouldDelete = (sourceDoc != 0);
}
return sourceDoc;
}
......@@ -302,23 +304,26 @@ bool XSLTProcessorImpl::transformToString(NodeImpl *sourceNode, QString &mimeTyp
}
cachedStylesheet->clearDocuments();
xmlDocPtr sourceDoc = xmlDocPtrFromNode(sourceNode);
const char **params = xsltParamArrayFromParameterMap(m_parameters);
xmlDocPtr resultDoc = xsltApplyStylesheet(sheet, sourceDoc, params);
freeXsltParamArray(params);
bool success = false;
bool shouldFreeSourceDoc = false;
if (xmlDocPtr sourceDoc = xmlDocPtrFromNode(sourceNode, shouldFreeSourceDoc)) {
const char **params = xsltParamArrayFromParameterMap(m_parameters);
xmlDocPtr resultDoc = xsltApplyStylesheet(sheet, sourceDoc, params);
freeXsltParamArray(params);
if (shouldFreeSourceDoc)
xmlFreeDoc(sourceDoc);
if (success = saveResultToString(resultDoc, sheet, resultString)) {
mimeType = resultMIMEType(resultDoc, sheet);
resultEncoding = (char *)resultDoc->encoding;
}
xmlFreeDoc(resultDoc);
}
setXSLTLoadCallBack(0, 0, 0);
if (!saveResultToString(resultDoc, sheet, resultString))
return false;
mimeType = resultMIMEType(resultDoc, sheet);
resultEncoding = (char *)resultDoc->encoding;
xsltFreeStylesheet(sheet);
xmlFreeDoc(resultDoc);
return true;
return success;
}
RefPtr<DocumentImpl> XSLTProcessorImpl::transformToDocument(NodeImpl *sourceNode)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment