From ae6cb678c6a9442506dd1b89f0de0c89bf540eb9 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Fri, 29 May 2015 17:13:49 +0800 Subject: [PATCH] Fix the memory leak of HttpClient on the iOS/Mac platform. --- cocos/network/HttpAsynConnection.m | 8 +++++--- cocos/network/HttpClient-apple.mm | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos/network/HttpAsynConnection.m b/cocos/network/HttpAsynConnection.m index 3ad078c892..59592fec71 100755 --- a/cocos/network/HttpAsynConnection.m +++ b/cocos/network/HttpAsynConnection.m @@ -51,10 +51,10 @@ [sslFile release]; [responseHeader release]; [responseData release]; - [statusString release]; [responseError release]; [conn release]; [runLoop release]; + [connError release]; [super dealloc]; } @@ -178,10 +178,12 @@ { CFDataRef errDataRef = SecTrustCopyExceptions(serverTrust); SecTrustSetExceptions(serverTrust, errDataRef); - SecTrustEvaluate(serverTrust, &trustResult); + [(id)errDataRef release]; } - + [certData release]; + [(id)certArrayRef release]; + [(id)certArrayRef release]; //Did our custom trust chain evaluate successfully? return trustResult = kSecTrustResultUnspecified || trustResult == kSecTrustResultProceed; } diff --git a/cocos/network/HttpClient-apple.mm b/cocos/network/HttpClient-apple.mm index 0e144acb5c..90ab992924 100644 --- a/cocos/network/HttpClient-apple.mm +++ b/cocos/network/HttpClient-apple.mm @@ -217,7 +217,7 @@ static int processTask(HttpClient* client, HttpRequest* request, NSString* reque long len = sslCaFileName.length(); long pos = sslCaFileName.rfind('.', len-1); - httpAsynConn.sslFile = [NSString stringWithUTF8String:sslCaFileName.substr(0, pos-1).c_str()]; + httpAsynConn.sslFile = [NSString stringWithUTF8String:sslCaFileName.substr(0, pos).c_str()]; } [httpAsynConn startRequest:nsrequest];