summaryrefslogtreecommitdiff
path: root/helpcompiler
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-04-17 10:56:03 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-04-17 10:57:00 +0900
commit6a964dcf0fe3b9258d07391ada0f0d245b1f7cec (patch)
treeb9af585607c69e5f8ccd227931eab42a4f9b824c /helpcompiler
parent326f8dc37bc11591e7d683b21085da7ee15b8072 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: Ibadadacbe09a93e7d7a7210868c52a8fa582d427
Diffstat (limited to 'helpcompiler')
-rw-r--r--helpcompiler/source/HelpLinker.cxx12
-rw-r--r--helpcompiler/source/HelpLinker_main.cxx4
2 files changed, 8 insertions, 8 deletions
diff --git a/helpcompiler/source/HelpLinker.cxx b/helpcompiler/source/HelpLinker.cxx
index 3e1cfd4d29d5..f98c9a2f0545 100644
--- a/helpcompiler/source/HelpLinker.cxx
+++ b/helpcompiler/source/HelpLinker.cxx
@@ -36,6 +36,8 @@
#include <rtl/bootstrap.hxx>
#include <expat.h>
+#include <boost/scoped_array.hpp>
+#include <boost/scoped_ptr.hpp>
IndexerPreProcessor::IndexerPreProcessor
( const std::string& aModuleName, const fs::path& fsIndexBaseDir,
@@ -946,9 +948,8 @@ HELPLINKER_DLLPUBLIC bool compileExtensionHelp
xmlSetStructuredErrorFunc( NULL, (xmlStructuredErrorFunc)StructuredXMLErrorFunction );
try
{
- HelpLinker* pHelpLinker = new HelpLinker();
+ boost::scoped_ptr<HelpLinker> pHelpLinker(new HelpLinker());
pHelpLinker->main( args, &aStdStrExtensionPath, &aStdStrDestination, &aOfficeHelpPath );
- delete pHelpLinker;
}
catch( const HelpProcessingException& e )
{
@@ -980,14 +981,14 @@ HELPLINKER_DLLPUBLIC bool compileExtensionHelp
aFileStatus.isValid( osl_FileStatus_Mask_FileSize ) )
{
sal_uInt64 ret, len = aFileStatus.getFileSize();
- char* s = new char[ int(len) ]; // the buffer to hold the installed files
+ boost::scoped_array<char> s(new char[ int(len) ]); // the buffer to hold the installed files
osl::File aFile( aTreeFileURL );
aFile.open( osl_File_OpenFlag_Read );
- aFile.read( s, len, ret );
+ aFile.read( s.get(), len, ret );
aFile.close();
XML_Parser parser = XML_ParserCreate( 0 );
- XML_Status parsed = XML_Parse( parser, s, int( len ), true );
+ XML_Status parsed = XML_Parse( parser, s.get(), int( len ), true );
if (XML_STATUS_ERROR == parsed)
{
@@ -1000,7 +1001,6 @@ HELPLINKER_DLLPUBLIC bool compileExtensionHelp
}
XML_ParserFree( parser );
- delete[] s;
}
return bSuccess;
diff --git a/helpcompiler/source/HelpLinker_main.cxx b/helpcompiler/source/HelpLinker_main.cxx
index 83906830b21c..dd22eb99ae8a 100644
--- a/helpcompiler/source/HelpLinker_main.cxx
+++ b/helpcompiler/source/HelpLinker_main.cxx
@@ -21,6 +21,7 @@
#include <HelpLinker.hxx>
#include <iostream>
#include <sal/main.h>
+#include <boost/scoped_ptr.hpp>
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
std::vector<std::string> args;
@@ -28,9 +29,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
args.push_back(std::string(argv[i]));
try
{
- HelpLinker* pHelpLinker = new HelpLinker();
+ boost::scoped_ptr<HelpLinker> pHelpLinker(new HelpLinker());
pHelpLinker->main( args );
- delete pHelpLinker;
}
catch( const HelpProcessingException& e )
{