From ec241d17ff4600899a7da9bce1074341e30a6a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 5 May 2015 11:33:39 -0400 Subject: [PATCH] Fixed NSMutableString leak Fixed analyzer warnings in http-nsurl target, which is MRR rather than ARC. --- platform/darwin/http_request_nsurl.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/platform/darwin/http_request_nsurl.mm b/platform/darwin/http_request_nsurl.mm index 509e158af..0006dbef8 100644 --- a/platform/darwin/http_request_nsurl.mm +++ b/platform/darwin/http_request_nsurl.mm @@ -153,7 +153,7 @@ void HTTPRequest::start() { @autoreleasepool { - NSMutableString *url = [[NSMutableString alloc] initWithString:@(resource.url.c_str())]; + NSMutableString *url = [NSMutableString stringWithString:@(resource.url.c_str())]; if ([[NSUserDefaults standardUserDefaults] objectForKey:@"mapbox_metrics_disabled"] == nil) { if ([url rangeOfString:@"?"].location == NSNotFound) { [url appendString:@"?"]; @@ -163,8 +163,7 @@ void HTTPRequest::start() { [url appendString:@"events=true"]; } - NSMutableURLRequest *req = [[NSMutableURLRequest alloc] - initWithURL:[NSURL URLWithString:url]]; + NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; if (existingResponse) { if (!existingResponse->etag.empty()) { [req addValue:@(existingResponse->etag.c_str()) forHTTPHeaderField:@"If-None-Match"]; @@ -179,7 +178,6 @@ void HTTPRequest::start() { task = [context->session dataTaskWithRequest:req completionHandler:^(NSData *data, NSURLResponse *res, NSError *error) { handleResult(data, res, error); }]; - [req release]; [task retain]; [task resume]; }