From d3029aa97052115c9c3e0e66c9c56fb335665443 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 1 Jun 2018 08:56:34 +0200 Subject: [PATCH] fix wrong memory mgt in iOS platform helper --- src/core/platform-helpers/ios-platform-helpers.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/platform-helpers/ios-platform-helpers.cpp b/src/core/platform-helpers/ios-platform-helpers.cpp index 8aa14cec4..57d14b21f 100644 --- a/src/core/platform-helpers/ios-platform-helpers.cpp +++ b/src/core/platform-helpers/ios-platform-helpers.cpp @@ -59,7 +59,7 @@ public: private: void bgTaskTimeout (); static void sBgTaskTimeout (void *data); - static const char *directoryForResource (CFStringRef framework, CFStringRef resource); + static std::string directoryForResource (CFStringRef framework, CFStringRef resource); long int mCpuLockTaskId; int mCpuLockCount; @@ -71,14 +71,14 @@ IosPlatformHelpers::IosPlatformHelpers (LinphoneCore *lc, void *system_context) mCpuLockCount = 0; mCpuLockTaskId = 0; - const char *cpimPath = directoryForResource(CFSTR("org.linphone.linphone"), CFSTR("cpim_grammar")); - const char *vcardPath = directoryForResource(CFSTR("org.linphone.belcard"), CFSTR("vcard_grammar")); - if (cpimPath) + std::string cpimPath = directoryForResource(CFSTR("org.linphone.linphone"), CFSTR("cpim_grammar")); + std::string vcardPath = directoryForResource(CFSTR("org.linphone.belcard"), CFSTR("vcard_grammar")); + if (!cpimPath.empty()) belr::GrammarLoader::get().addPath(cpimPath); else lError() << "IosPlatformHelpers did not find cpim grammar resource directory..."; - if (vcardPath) + if (!vcardPath.empty()) belr::GrammarLoader::get().addPath(vcardPath); else lError() << "IosPlatformHelpers did not find vcard grammar resource directory..."; @@ -125,13 +125,13 @@ void IosPlatformHelpers::releaseCpuLock () { mCpuLockTaskId = 0; } -const char *IosPlatformHelpers::directoryForResource (CFStringRef framework, CFStringRef resource) { +std::string IosPlatformHelpers::directoryForResource (CFStringRef framework, CFStringRef resource) { CFBundleRef bundle = CFBundleGetBundleWithIdentifier(framework); CFURLRef grammarUrl = CFBundleCopyResourceURL(bundle, resource, nullptr, nullptr); CFURLRef grammarUrlDirectory = CFURLCreateCopyDeletingLastPathComponent(nullptr, grammarUrl); CFStringRef grammarPath = CFURLCopyFileSystemPath(grammarUrlDirectory, kCFURLPOSIXPathStyle); CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); - const char *path = CFStringGetCStringPtr(grammarPath, encodingMethod); + std::string path(CFStringGetCStringPtr(grammarPath, encodingMethod)); CFRelease(grammarUrl); CFRelease(grammarPath); CFRelease(grammarUrlDirectory);