diff options
Diffstat (limited to 'Source/CPack/OSXScriptLauncher.cxx')
-rw-r--r-- | Source/CPack/OSXScriptLauncher.cxx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index 21d27a02d..bdaf779af 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -5,6 +5,8 @@ #include <string> #include <vector> +#include <cm/memory> + #include <CoreFoundation/CoreFoundation.h> #include "cmsys/FStream.hxx" @@ -26,7 +28,6 @@ int main(int argc, char* argv[]) CFStringRef fileName; CFBundleRef appBundle; CFURLRef scriptFileURL; - UInt8* path; // get CF URL for script if (!(appBundle = CFBundleGetMainBundle())) { @@ -41,13 +42,15 @@ int main(int argc, char* argv[]) } // create path string - if (!(path = new UInt8[PATH_MAX])) { + auto path = cm::make_unique<UInt8[]>(PATH_MAX); + if (!path) { return 1; } // get the file system path of the url as a cstring // in an encoding suitable for posix apis - if (!CFURLGetFileSystemRepresentation(scriptFileURL, true, path, PATH_MAX)) { + if (!CFURLGetFileSystemRepresentation(scriptFileURL, true, path.get(), + PATH_MAX)) { DebugError("CFURLGetFileSystemRepresentation failed"); return 1; } @@ -55,10 +58,10 @@ int main(int argc, char* argv[]) // dispose of the CF variable CFRelease(scriptFileURL); - std::string fullScriptPath = reinterpret_cast<char*>(path); - delete[] path; + std::string fullScriptPath = reinterpret_cast<char*>(path.get()); + path.reset(); - if (!cmsys::SystemTools::FileExists(fullScriptPath.c_str())) { + if (!cmsys::SystemTools::FileExists(fullScriptPath)) { return 1; } @@ -80,7 +83,6 @@ int main(int argc, char* argv[]) cmsysProcess_SetTimeout(cp, 0); cmsysProcess_Execute(cp); - std::vector<char> tempOutput; char* data; int length; while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) { |