BUG: don't crash when loading a module that does not exist

This commit is contained in:
Bill Hoffman 2004-02-17 08:35:23 -05:00
parent 5a391f8aa7
commit 8f565bdc74
1 changed files with 11 additions and 4 deletions

View File

@ -162,12 +162,19 @@ cmLibHandle cmDynamicLoader::OpenLibrary(const char* libname )
}
NSObjectFileImageReturnCode rc;
NSObjectFileImage image;
NSObjectFileImage image = 0;
rc = NSCreateObjectFileImageFromFile(libname, &image);
if(!image)
{
return 0;
}
lh = NSLinkModule(image, libname, TRUE);
cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh);
return lh;
if(lh)
{
cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh);
}
return lh;
}
int cmDynamicLoader::CloseLibrary(cmLibHandle lib)
@ -334,6 +341,6 @@ const char* cmDynamicLoader::LibPrefix()
const char* cmDynamicLoader::LibExtension()
{
return CMAKE_SHARED_LIBRARY_SUFFIX;
return CMAKE_SHARED_MODULE_SUFFIX;
}