ensure bundle url is there before making a C string from it

This commit is contained in:
Ariel Elkin
2014-03-14 17:51:41 +00:00
parent 3e43d5e297
commit b5e24dec52

View File

@@ -89,6 +89,7 @@ void Stk :: setRawwavePathForDynamicallyLoadedRawwaves ( void )
#ifdef __OS_IOS__ #ifdef __OS_IOS__
CFBundleRef mainBundle = CFBundleGetMainBundle(); CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef url = CFBundleCopyResourceURL(mainBundle, CFSTR("rawwaves"), CFSTR("bundle"), NULL); CFURLRef url = CFBundleCopyResourceURL(mainBundle, CFSTR("rawwaves"), CFSTR("bundle"), NULL);
if (url) {
CFStringRef rawwavesPathCFString = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); CFStringRef rawwavesPathCFString = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
CFIndex length = CFStringGetLength(rawwavesPathCFString); CFIndex length = CFStringGetLength(rawwavesPathCFString);
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
@@ -99,6 +100,7 @@ void Stk :: setRawwavePathForDynamicallyLoadedRawwaves ( void )
CFRelease(url); CFRelease(url);
CFRelease(rawwavesPathCFString); CFRelease(rawwavesPathCFString);
}
#endif #endif
rawwavesPathSet = true; rawwavesPathSet = true;
} }