dbertoni 01/01/30 17:41:41
Modified: c/src/XSLT StylesheetHandler.cpp
Log:
Fixed memory leak during exception throw with invalid child. Make sure to
check for a default namespace declaration when checking for an HTML literal
result element as the stylesheet.
Revision Changes Path
1.54 +22 -2 xml-xalan/c/src/XSLT/StylesheetHandler.cpp
Index: StylesheetHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- StylesheetHandler.cpp 2001/01/29 01:11:49 1.53
+++ StylesheetHandler.cpp 2001/01/31 01:41:41 1.54
@@ -68,6 +68,10 @@
+#include <DOMSupport/DOMServices.hpp>
+
+
+
#include <XMLSupport/Formatter.hpp>
@@ -1030,8 +1034,17 @@
if(!m_elemStack.empty())
{
ElemTemplateElement* const parent =
m_elemStack.back();
+
+ // Guard against an exception in
appendChildElem()...
+ XalanAutoPtr<ElemTemplateElement>
theGuard(elem);
+
parent->appendChildElem(elem);
+
m_elemStackParentedElements.insert(elem);
+
+ // The element is parented and will now be
+ // deleted when the parent is delete...
+ theGuard.release();
}
m_elemStack.push_back(elem);
@@ -1128,10 +1141,17 @@
m_foundStylesheet = true;
m_stylesheet.setWrapperless(true);
+ // This attempts to optimize for a literal result element with
+ // the name HTML, so we don't have to switch on-the-fly.
if(equalsIgnoreCase(name, Constants::ELEMNAME_HTML_STRING) == true)
{
- m_stylesheet.getStylesheetRoot().setIndentResult(true);
-
m_stylesheet.getStylesheetRoot().setOutputMethod(OUTPUT_METHOD_HTML);
+ // If there's a default namespace, then we must output XML.
+ // Otherwise, we'll set the output method to HTML.
+ if (atts.getValue(c_wstr(DOMServices::s_XMLNamespace)) == 0)
+ {
+ m_stylesheet.getStylesheetRoot().setIndentResult(true);
+
m_stylesheet.getStylesheetRoot().setOutputMethod(OUTPUT_METHOD_HTML);
+ }
}
return pElem;