Browse Source

Fix crash if app bundle executeable couldn't be found

Fix a crash on Mac OS X if a programm can't be found as an
application bundle. CFRelease MUST NOT be called on a
NULL value.

See https://developer.apple.com/library/mac/documentation/CoreFOundation/Reference/CFTypeRef/Reference/reference.html#//apple_ref/doc/c_ref/CFRelease
Bjoern Ricks 13 years ago
parent
commit
0d2f5c8d6a
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Source/cmFindProgramCommand.cxx

+ 2 - 1
Source/cmFindProgramCommand.cxx

@@ -175,6 +175,8 @@ std::string cmFindProgramCommand::GetBundleExecutable(std::string bundlePath)
     
     // And finally to a c++ string
     executable = bundlePath + "/Contents/MacOS/" + std::string(buffer);
+    // Only release CFURLRef if it's not null
+    CFRelease( executableURL );
     }
 
   // Any CF objects returned from functions with "create" or 
@@ -182,7 +184,6 @@ std::string cmFindProgramCommand::GetBundleExecutable(std::string bundlePath)
   CFRelease( bundlePathCFS );
   CFRelease( bundleURL );
   CFRelease( appBundle );
-  CFRelease( executableURL );
 #endif
 
   return executable;