From ee50668e2f49dc30da485d3c242c52880c046c7e Mon Sep 17 00:00:00 2001 From: RĂ¼diger Timm Date: Tue, 8 Jul 2008 08:42:15 +0000 Subject: INTEGRATION: CWS fwk91 (1.6.6); FILE MERGED 2008/06/24 11:38:59 mst 1.6.6.1: fix #i90835# - unoxml/source/dom/documentbuilder.cxx: + do not access freed xmlParserCtxt --- unoxml/source/dom/documentbuilder.cxx | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'unoxml') diff --git a/unoxml/source/dom/documentbuilder.cxx b/unoxml/source/dom/documentbuilder.cxx index d556b431385e..7f6777620d87 100644 --- a/unoxml/source/dom/documentbuilder.cxx +++ b/unoxml/source/dom/documentbuilder.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: documentbuilder.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * @@ -316,6 +316,16 @@ namespace DOM } // extern "C" + void throwEx(xmlParserCtxtPtr ctxt) { + OUString msg = make_error_message(ctxt); + xmlFreeParserCtxt(ctxt); + com::sun::star::xml::sax::SAXParseException saxex; + saxex.Message = msg; + saxex.LineNumber = static_cast(ctxt->lastError.line); + saxex.ColumnNumber = static_cast(ctxt->lastError.int2); + throw saxex; + } + Reference< XDocument > SAL_CALL CDocumentBuilder::parse(const Reference< XInputStream >& is) throw (RuntimeException, SAXParseException, IOException) { @@ -345,15 +355,10 @@ namespace DOM xmlDocPtr pDoc = xmlCtxtReadIO(ctxt, xmlIO_read_func, xmlIO_close_func, &c, 0, 0, 0); - xmlFreeParserCtxt(ctxt); if (pDoc == 0) { - OUString msg = make_error_message(ctxt); - com::sun::star::xml::sax::SAXParseException saxex; - saxex.Message = msg; - saxex.LineNumber = static_cast(ctxt->lastError.line); - saxex.ColumnNumber = static_cast(ctxt->lastError.int2); - throw saxex; + throwEx(ctxt); } + xmlFreeParserCtxt(ctxt); return Reference< XDocument >(static_cast< CDocument* >(CNode::get((xmlNodePtr)pDoc))); } @@ -399,15 +404,10 @@ namespace DOM OString oUri = OUStringToOString(sUri, RTL_TEXTENCODING_UTF8); char *uri = (char*) oUri.getStr(); xmlDocPtr pDoc = xmlCtxtReadFile(ctxt, uri, 0, 0); - xmlFreeParserCtxt(ctxt); if (pDoc == 0) { - OUString msg = make_error_message(ctxt); - com::sun::star::xml::sax::SAXParseException saxex; - saxex.Message = msg; - saxex.LineNumber = static_cast(ctxt->lastError.line); - saxex.ColumnNumber = static_cast(ctxt->lastError.int2); - throw saxex; + throwEx(ctxt); } + xmlFreeParserCtxt(ctxt); return Reference< XDocument >(static_cast< CDocument* >(CNode::get((xmlNodePtr)pDoc))); } -- cgit