From 44a39cc44f0c053ae1204c8370d3d135a1e492bd Mon Sep 17 00:00:00 2001 From: Michael Sotnikov Date: Wed, 29 Apr 2015 16:09:19 +0300 Subject: [PATCH] fix memory leaks --- protocols/platform/ios/AdsWrapper.mm | 2 +- protocols/platform/ios/ParseUtils.m | 2 +- protocols/platform/ios/PluginFactory.mm | 1 + protocols/platform/ios/PluginUtilsIOS.mm | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/protocols/platform/ios/AdsWrapper.mm b/protocols/platform/ios/AdsWrapper.mm index ccf13350..a4778cbe 100644 --- a/protocols/platform/ios/AdsWrapper.mm +++ b/protocols/platform/ios/AdsWrapper.mm @@ -76,7 +76,7 @@ + (NSString*)buildVersion // adapted from http://stackoverflow.com/questions/25540140/can-one-determine-the-ios-sdk-version-used-to-build-a-binary-programmatically // form character set of digits and punctuation - NSMutableCharacterSet *characterSet = [[NSCharacterSet decimalDigitCharacterSet] mutableCopy]; + NSMutableCharacterSet *characterSet = [[[NSCharacterSet decimalDigitCharacterSet] mutableCopy] autorelease]; [characterSet formUnionWithCharacterSet: [NSCharacterSet punctuationCharacterSet]]; diff --git a/protocols/platform/ios/ParseUtils.m b/protocols/platform/ios/ParseUtils.m index 95e2e49e..09cfc21e 100644 --- a/protocols/platform/ios/ParseUtils.m +++ b/protocols/platform/ios/ParseUtils.m @@ -47,7 +47,7 @@ + (NSString *) NSDictionaryToNSString:(id)dic{ if (! jsonData) { NSLog(@"Got an error: %@", error); } else { - result = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + result = [[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding] autorelease]; } return result; } diff --git a/protocols/platform/ios/PluginFactory.mm b/protocols/platform/ios/PluginFactory.mm index 788156ff..b2eb9b66 100644 --- a/protocols/platform/ios/PluginFactory.mm +++ b/protocols/platform/ios/PluginFactory.mm @@ -116,6 +116,7 @@ of this software and associated documentation files (the "Software"), to deal pRet->setPluginName(name); PluginUtilsIOS::initOCPlugin(pRet, obj, name); } + [obj release]; } while(0); return pRet; diff --git a/protocols/platform/ios/PluginUtilsIOS.mm b/protocols/platform/ios/PluginUtilsIOS.mm index 4cb1d34c..76fa2110 100644 --- a/protocols/platform/ios/PluginUtilsIOS.mm +++ b/protocols/platform/ios/PluginUtilsIOS.mm @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal void PluginUtilsIOS::initOCPlugin(PluginProtocol* pPlugin, id ocObj, const char* className) { PluginOCData* pData = new PluginOCData(); - pData->obj = ocObj; + pData->obj = [ocObj retain]; pData->className = className; PluginUtilsIOS::setPluginOCData(pPlugin, pData); }