diff options
author | Robert Nagy <robert@openbsd.org> | 2011-04-05 21:58:11 +0200 |
---|---|---|
committer | Robert Nagy <robert@openbsd.org> | 2011-04-05 21:58:11 +0200 |
commit | 8eb7fb67ca55e59485b0b983e7faf6a987f9e7ee (patch) | |
tree | 97400c4cbedea850adf625370a70c79a40165bd9 /desktop | |
parent | f048183de102118b190a8cd7026ab020529a4db5 (diff) |
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.
Diffstat (limited to 'desktop')
-rwxr-xr-x | desktop/unx/source/start.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c index fcb2daf461ab..e81cd6129d0a 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; } |