From 407db844120ead0d57118c40ab5e6acc1bad736d Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 22 May 2014 18:51:57 +0200 Subject: Fix memory leak in xrmex tool Change-Id: I102566a95b5b34daf60730ffef290913caf28eb2 --- l10ntools/inc/xrmlex.hxx | 2 +- l10ntools/source/xrmlex.l | 5 +---- l10ntools/source/xrmmerge.cxx | 8 +++----- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'l10ntools') diff --git a/l10ntools/inc/xrmlex.hxx b/l10ntools/inc/xrmlex.hxx index 2b159283d222..e1092433f2b6 100644 --- a/l10ntools/inc/xrmlex.hxx +++ b/l10ntools/inc/xrmlex.hxx @@ -30,7 +30,7 @@ extern "C" int InitXrmExport( const char * ); extern "C" int EndXrmExport(); extern "C" int GetError(); extern "C" int SetError(); -extern "C" char *GetOutputFile( int argc, char* argv[]); +extern "C" bool GetOutputFile( int argc, char* argv[]); extern "C" FILE *GetXrmFile(); extern "C" int isQuiet(); extern "C" const char* getFilename(); diff --git a/l10ntools/source/xrmlex.l b/l10ntools/source/xrmlex.l index f91405f60655..c29406e030f4 100644 --- a/l10ntools/source/xrmlex.l +++ b/l10ntools/source/xrmlex.l @@ -205,12 +205,9 @@ void yyerror ( const char *s ) SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) { /* error level */ int nRetValue = 0; - char *pOutput; FILE *pFile; - pOutput = GetOutputFile( argc, argv ); - - if ( !pOutput ) + if ( !GetOutputFile( argc, argv ) ) { return 1; } diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index 37190fb58623..510fc1a099fa 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -54,7 +54,7 @@ XRMResParser *pParser = NULL; extern "C" { // the whole interface to lexer is in this extern "C" section -extern char *GetOutputFile( int argc, char* argv[]) +extern bool GetOutputFile( int argc, char* argv[]) { bDisplayName = false; bExtensionDescription = false; @@ -67,15 +67,13 @@ extern char *GetOutputFile( int argc, char* argv[]) sInputFileName = aArgs.m_sInputFile; sOutputFile = aArgs.m_sOutputFile; sMergeSrc = aArgs.m_sMergeSrc; - char *pReturn = new char[ sOutputFile.getLength() + 1 ]; - std::strcpy( pReturn, sOutputFile.getStr()); - return pReturn; + return true; } else { // command line is not valid common::writeUsage("xrmex","*.xrm/*.xml"); - return NULL; + return false; } } -- cgit