@@ -207,13 +207,15 @@ static CFURLRef _CFBundleCopyExecutableURLInDirectory2(CFBundleRef bundle, CFURL
207
207
if (lookupMainExe && bundle && bundle -> _isFHSInstalledBundle ) {
208
208
// For a FHS installed bundle, the URL points to share/Bundle.resources, and the binary is in:
209
209
210
- CFURLRef prefix = CFURLCreateCopyDeletingLastPathComponent (kCFAllocatorSystemDefault , url );
211
-
210
+ CFURLRef sharePath = CFURLCreateCopyDeletingLastPathComponent (kCFAllocatorSystemDefault , url );
211
+ CFURLRef prefixPath = CFURLCreateCopyDeletingLastPathComponent (kCFAllocatorSystemDefault , sharePath );
212
+ CFRelease (sharePath );
213
+
212
214
CFStringRef directories [] = { _CFBundleFHSDirectoriesInExecutableSearchOrder };
213
215
size_t directoriesCount = sizeof (directories ) / sizeof (directories [0 ]);
214
216
215
217
for (size_t i = 0 ; i < directoriesCount ; i ++ ) {
216
- CFURLRef where = CFURLCreateCopyAppendingPathComponent (kCFAllocatorSystemDefault , prefix , directories [i ], true);
218
+ CFURLRef where = CFURLCreateCopyAppendingPathComponent (kCFAllocatorSystemDefault , prefixPath , directories [i ], true);
217
219
executableURL = _CFBundleCopyExecutableURLRaw (where , executableName );
218
220
CFRelease (where );
219
221
@@ -223,7 +225,7 @@ static CFURLRef _CFBundleCopyExecutableURLInDirectory2(CFBundleRef bundle, CFURL
223
225
}
224
226
}
225
227
226
- CFRelease (prefix );
228
+ CFRelease (prefixPath );
227
229
}
228
230
#endif // !DEPLOYMENT_RUNTIME_OBJC && !DEPLOYMENT_TARGET_WINDOWS
229
231
@@ -290,11 +292,7 @@ static CFURLRef _CFBundleCopyExecutableURLInDirectory2(CFBundleRef bundle, CFURL
290
292
if (lookupMainExe && !ignoreCache && bundle && executableURL ) {
291
293
// We found it. Cache the path.
292
294
CFURLRef absURL = CFURLCopyAbsoluteURL (executableURL );
293
- #if DEPLOYMENT_TARGET_WINDOWS
294
- executablePath = CFURLCopyFileSystemPath (absURL , kCFURLWindowsPathStyle );
295
- #else
296
- executablePath = CFURLCopyFileSystemPath (absURL , kCFURLPOSIXPathStyle );
297
- #endif
295
+ executablePath = CFURLCopyFileSystemPath (absURL , PLATFORM_PATH_STYLE );
298
296
CFRelease (absURL );
299
297
__CFLock (& bundle -> _lock );
300
298
bundle -> _executablePath = (CFStringRef )CFRetain (executablePath );
0 commit comments