[Libreoffice-commits] .: Branch 'libreoffice-3-4' - desktop/unx

Robert Nagy rnagy at kemper.freedesktop.org
Tue Apr 5 13:01:36 PDT 2011


 desktop/unx/source/start.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 3c7ca79ca63bcee9c8943cd2dc30984c0820eb8a
Author: Robert Nagy <robert at openbsd.org>
Date:   Tue Apr 5 21:58:11 2011 +0200

    pass pOrigPath (strdup'd) to dirname(3) instead of pPath to avoid double free
    
    from the dirname(3) manual:
    Both dirname() and basename() may modify the contents of path, so copies
    should be passed to these functions.
    Furthermore, dirname() and basename() may return pointers to statically
    allocated memory which may be overwritten by subsequent calls.

diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index 19420a9..b0f5ab3 100755
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -216,12 +216,12 @@ get_app_path( const char *pAppExec )
     char pRealPath[PATH_MAX];
     rtl_uString *pResult;
 
-    char *pPath = strdup( pAppExec );
-    pPath = dirname( pPath );
+    char *pOrigPath = strdup( pAppExec );
+    char *pPath = dirname( pOrigPath );
 
     realpath( pPath, pRealPath );
     pResult = charp_to_ustr( pRealPath );
-    free( pPath );
+    free( pOrigPath );
 
     return pResult;
 }


More information about the Libreoffice-commits mailing list