[Libreoffice-commits] .: Branch 'feature/killsdf' - l10ntools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 8 09:31:26 PDT 2012


 l10ntools/source/cfgmerge.cxx |   10 +++++-----
 l10ntools/source/export.cxx   |   19 ++++++++++---------
 2 files changed, 15 insertions(+), 14 deletions(-)

New commits:
commit 73ed390a7ff6b701b89faf91385aaa63e865e441
Author: Zolnai Tamás <zolnaitamas2000 at gmail.com>
Date:   Mon Oct 8 18:23:31 2012 +0200

    Correct wrong memory addressing
    
    Some global variables in export.cxx and
    cfgmerge.cxx pointed to OString databuffer
    and after these strings are destroyed the pointers
    refered to invalid address.
    Use OString instead of const char*
    
    Change-Id: I4ea43f4b3772ef3370d79336559d39a67400fe2b

diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx
index 3eb442f..1d0a819 100644
--- a/l10ntools/source/cfgmerge.cxx
+++ b/l10ntools/source/cfgmerge.cxx
@@ -38,7 +38,7 @@ namespace {
 
 namespace global {
 
-char const * inputPathname = 0;
+OString inputPathname;
 boost::scoped_ptr< CfgParser > parser;
 
 }
@@ -55,13 +55,13 @@ FILE * init(int argc, char ** argv) {
         std::exit(EXIT_FAILURE);
     }
     Export::InitLanguages();
-    global::inputPathname = aArgs.m_sInputFile.getStr();
+    global::inputPathname = aArgs.m_sInputFile;
 
-    FILE * pFile = std::fopen(global::inputPathname, "r");
+    FILE * pFile = std::fopen(global::inputPathname.getStr(), "r");
     if (pFile == 0) {
         std::fprintf(
             stderr, "Error: Cannot open file \"%s\"\n",
-            global::inputPathname);
+            global::inputPathname.getStr() );
         std::exit(EXIT_FAILURE);
     }
 
@@ -74,7 +74,7 @@ FILE * init(int argc, char ** argv) {
         global::parser.reset(
             new CfgExport(
                 aArgs.m_sOutputFile.getStr(), aArgs.m_sPrj.getStr(),
-                common::pathnameToken(global::inputPathname,
+                common::pathnameToken(global::inputPathname.getStr(),
                 aArgs.m_sPrjRoot.getStr())));
     }
 
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index d9dd5ac..13870da 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -42,9 +42,9 @@ MergeDataFile * pMergeDataFile = 0; //TODO
 
 namespace global {
 
-char const * prj = 0;
-char const * prjRoot = 0;
-char const * inputPathname = 0;
+OString prj;
+OString prjRoot;
+OString inputPathname;
 boost::scoped_ptr< Export > exporter;
 
 }
@@ -61,15 +61,15 @@ FILE * init(int argc, char ** argv) {
         std::exit(EXIT_FAILURE);
     }
     Export::InitLanguages();
-    global::prj =  aArgs.m_sPrj.getStr();
-    global::prjRoot =  aArgs.m_sPrjRoot.getStr();
-    global::inputPathname =  aArgs.m_sInputFile.getStr();
+    global::prj =  aArgs.m_sPrj;
+    global::prjRoot =  aArgs.m_sPrjRoot;
+    global::inputPathname =  aArgs.m_sInputFile;
 
-    FILE * pFile = std::fopen(global::inputPathname, "r");
+    FILE * pFile = std::fopen(global::inputPathname.getStr(), "r");
     if (pFile == 0) {
         std::fprintf(
             stderr, "Error: Cannot open file \"%s\"\n",
-            global::inputPathname);
+            global::inputPathname.getStr());
         std::exit(EXIT_FAILURE);
     }
 
@@ -78,7 +78,8 @@ FILE * init(int argc, char ** argv) {
             new Export(aArgs.m_sMergeSrc.getStr(), aArgs.m_sOutputFile.getStr()));
     } else {
         sActFileName =
-            common::pathnameToken(global::inputPathname, global::prjRoot);
+            common::pathnameToken(
+                global::inputPathname.getStr(), global::prjRoot.getStr());
         global::exporter.reset(new Export(aArgs.m_sOutputFile.getStr()));
     }
 


More information about the Libreoffice-commits mailing list