diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-01-11 17:21:56 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-02-04 14:03:13 +0100 |
commit | 19badc4def7d2bee677da3a02e1117f1e051a8cd (patch) | |
tree | 2dc20f1bcbda813d2616b32856994f558a4c1eab /win/rfb_win32/LaunchProcess.cxx | |
parent | 337dbc392253af92b0577da062a5abc1d032b1ef (diff) | |
download | tigervnc-19badc4def7d2bee677da3a02e1117f1e051a8cd.tar.gz tigervnc-19badc4def7d2bee677da3a02e1117f1e051a8cd.zip |
Make strSplit() simpler and safer
Get rid of all the magical re-allocation and shuffling and instead just
return a new set of strings that is fully splitted. Will consume a bit
more memory, but is a lot safer to use as there is less confusion about
ownership of memory.
Diffstat (limited to 'win/rfb_win32/LaunchProcess.cxx')
-rw-r--r-- | win/rfb_win32/LaunchProcess.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/win/rfb_win32/LaunchProcess.cxx b/win/rfb_win32/LaunchProcess.cxx index 13d7e950..7d17caf7 100644 --- a/win/rfb_win32/LaunchProcess.cxx +++ b/win/rfb_win32/LaunchProcess.cxx @@ -67,7 +67,9 @@ void LaunchProcess::start(HANDLE userToken, bool createConsole) { CharArray exePath; if (!strContains(exeName.buf, '\\')) { ModuleFileName filename; - CharArray path; splitPath(filename.buf, &path.buf, 0); + CharArray path(strDup(filename.buf)); + if (strContains(path.buf, '\\')) + *strrchr(path.buf, '\\') = '\0'; exePath.buf = new char[strlen(path.buf) + strlen(exeName.buf) + 2]; sprintf(exePath.buf, "%s\\%s", path.buf, exeName.buf); } else { |