summaryrefslogtreecommitdiffstats
path: root/Source/cmFindProgramCommand.cxx
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2020-06-14 08:21:35 (GMT)
committerCraig Scott <craig.scott@crascit.com>2020-06-14 08:21:35 (GMT)
commitd3fd518c0316b15e4680c32808788935bf8c5c3d (patch)
tree6a843d0dbfdb639f206c3693bc007a5d017de555 /Source/cmFindProgramCommand.cxx
parent6dc7c1f85d7a01917f7f239866f88ebc3268df89 (diff)
downloadCMake-d3fd518c0316b15e4680c32808788935bf8c5c3d.zip
CMake-d3fd518c0316b15e4680c32808788935bf8c5c3d.tar.gz
CMake-d3fd518c0316b15e4680c32808788935bf8c5c3d.tar.bz2
find_program: Properly decode URL for bundle exe name with spaces
Fixes: #20817
Diffstat (limited to 'Source/cmFindProgramCommand.cxx')
-rw-r--r--Source/cmFindProgramCommand.cxx13
1 files changed, 6 insertions, 7 deletions
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index 599b1d2..d4b0ee1 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -266,14 +266,13 @@ std::string cmFindProgramCommand::GetBundleExecutable(
if (executableURL != nullptr) {
const int MAX_OSX_PATH_SIZE = 1024;
- char buffer[MAX_OSX_PATH_SIZE];
+ UInt8 buffer[MAX_OSX_PATH_SIZE];
- // Convert the CFString to a C string
- CFStringGetCString(CFURLGetString(executableURL), buffer,
- MAX_OSX_PATH_SIZE, kCFStringEncodingUTF8);
-
- // And finally to a c++ string
- executable = bundlePath + "/Contents/MacOS/" + std::string(buffer);
+ if (CFURLGetFileSystemRepresentation(executableURL, false, buffer,
+ MAX_OSX_PATH_SIZE)) {
+ executable = bundlePath + "/Contents/MacOS/" +
+ std::string(reinterpret_cast<char*>(buffer));
+ }
// Only release CFURLRef if it's not null
CFRelease(executableURL);
}