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 1/5] 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]; } From 900d140f23b28c56ab01fc227b5cf74a71e81650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 5 May 2015 11:41:02 -0400 Subject: [PATCH 2/5] Fixed dead store analyzer warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These values weren’t being used for anything. --- platform/ios/MGLMapboxEvents.m | 1 - platform/ios/MGLMetricsLocationManager.m | 17 ----------------- src/clipper/clipper.cpp | 1 - src/libtess2/mesh.c | 3 --- 4 files changed, 22 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 36ed63d33..67e51158e 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -699,7 +699,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { SecTrustRef serverTrust = [[challenge protectionSpace] serverTrust]; - NSString *domain = [[challenge protectionSpace] host]; SecTrustResultType trustResult; // Validate the certificate chain with the device's trust store anyway diff --git a/platform/ios/MGLMetricsLocationManager.m b/platform/ios/MGLMetricsLocationManager.m index 848b4a051..9c186e4bf 100644 --- a/platform/ios/MGLMetricsLocationManager.m +++ b/platform/ios/MGLMetricsLocationManager.m @@ -89,34 +89,17 @@ } - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { - NSString *newStatus = nil; switch (status) { - case kCLAuthorizationStatusNotDetermined: - newStatus = @"User Hasn't Determined Yet"; - break; - case kCLAuthorizationStatusRestricted: - newStatus = @"Restricted and Can't Be Changed By User"; - break; case kCLAuthorizationStatusDenied: - newStatus = @"User Explcitly Denied"; [self stopUpdatingLocation]; [self stopMonitoringVisits]; break; case kCLAuthorizationStatusAuthorized: - newStatus = @"User Has Authorized / Authorized Always"; - [self startUpdatingLocation]; - [self startMonitoringVisits]; - break; -// case kCLAuthorizationStatusAuthorizedAlways: -// newStatus = @"Not Determined"; -// break; case kCLAuthorizationStatusAuthorizedWhenInUse: - newStatus = @"User Has Authorized When In Use Only"; [self startUpdatingLocation]; [self startMonitoringVisits]; break; default: - newStatus = @"Unknown"; break; } } diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index f5d8cd3c9..9741ad7cd 100755 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -4136,7 +4136,6 @@ void ClipperOffset::DoOffset(double delta) } else { - k = 1; m_sinA = 0; if (node.m_endtype == etOpenSquare) DoSquare(0, 1); diff --git a/src/libtess2/mesh.c b/src/libtess2/mesh.c index 3eb4ad20a..43b442f4b 100755 --- a/src/libtess2/mesh.c +++ b/src/libtess2/mesh.c @@ -794,7 +794,6 @@ void tessMeshCheckMesh( TESSmesh *mesh ) TESSvertex *v, *vPrev; TESShalfEdge *e, *ePrev; - fPrev = fHead; for( fPrev = fHead ; (f = fPrev->next) != fHead; fPrev = f) { assert( f->prev == fPrev ); e = f->anEdge; @@ -809,7 +808,6 @@ void tessMeshCheckMesh( TESSmesh *mesh ) } assert( f->prev == fPrev && f->anEdge == NULL ); - vPrev = vHead; for( vPrev = vHead ; (v = vPrev->next) != vHead; vPrev = v) { assert( v->prev == vPrev ); e = v->anEdge; @@ -824,7 +822,6 @@ void tessMeshCheckMesh( TESSmesh *mesh ) } assert( v->prev == vPrev && v->anEdge == NULL ); - ePrev = eHead; for( ePrev = eHead ; (e = ePrev->next) != eHead; ePrev = e) { assert( e->Sym->next == ePrev->Sym ); assert( e->Sym != e ); From fc576ddef67e15027d027bdc486b0723b8383af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 5 May 2015 12:02:47 -0400 Subject: [PATCH 3/5] Suppressed an uninitialized value warning from the static analyzer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While tracking the user’s location, a double tap not near the user dot now turns off location tracking instead of bouncing between the tapped location and the user location. --- platform/ios/MGLMapView.mm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 6c4875546..3ea7c0cec 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1077,22 +1077,19 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration) { CGPoint doubleTapPoint = [doubleTap locationInView:doubleTap.view]; - CGPoint zoomInPoint; - + CGPoint zoomInPoint = doubleTapPoint; + CGPoint userPoint = [self convertCoordinate:self.userLocation.coordinate toPointToView:self]; if (self.userTrackingMode != MGLUserTrackingModeNone) { - CGPoint userPoint = [self convertCoordinate:self.userLocation.coordinate toPointToView:self]; CGRect userLocationRect = CGRectMake(userPoint.x - 40, userPoint.y - 40, 80, 80); if (CGRectContainsPoint(userLocationRect, doubleTapPoint)) { zoomInPoint = userPoint; } } - else + if ( ! CGPointEqualToPoint(zoomInPoint, userPoint)) { self.userTrackingMode = MGLUserTrackingModeNone; - - zoomInPoint = doubleTapPoint; } _mbglMap->scaleBy(2, zoomInPoint.x, zoomInPoint.y, secondsAsDuration(MGLAnimationDuration)); From ec3757309f6db3ad5a583129c62f245893ecb72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 5 May 2015 12:10:44 -0400 Subject: [PATCH 4/5] Fixed leaks of copied CF objects --- platform/ios/MGLMapboxEvents.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 67e51158e..4450fa87f 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -617,10 +617,11 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; NSString *ssid = nil; CFArrayRef interfaces = CNCopySupportedInterfaces(); if (interfaces) { - NSDictionary *info = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0)); + NSDictionary *info = CFBridgingRelease(CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0))); if (info) { ssid = info[@"SSID"]; } + CFRelease(interfaces); } return ssid; From 4898751f48d3c27c0fd127c278a238834eb953b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Wed, 6 May 2015 12:06:13 -0700 Subject: [PATCH 5/5] Rolled back portions of 900d140f23b28c56ab01fc227b5cf74a71e81650 that should go upstream --- src/clipper/clipper.cpp | 1 + src/libtess2/mesh.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 9741ad7cd..f5d8cd3c9 100755 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -4136,6 +4136,7 @@ void ClipperOffset::DoOffset(double delta) } else { + k = 1; m_sinA = 0; if (node.m_endtype == etOpenSquare) DoSquare(0, 1); diff --git a/src/libtess2/mesh.c b/src/libtess2/mesh.c index 43b442f4b..3eb4ad20a 100755 --- a/src/libtess2/mesh.c +++ b/src/libtess2/mesh.c @@ -794,6 +794,7 @@ void tessMeshCheckMesh( TESSmesh *mesh ) TESSvertex *v, *vPrev; TESShalfEdge *e, *ePrev; + fPrev = fHead; for( fPrev = fHead ; (f = fPrev->next) != fHead; fPrev = f) { assert( f->prev == fPrev ); e = f->anEdge; @@ -808,6 +809,7 @@ void tessMeshCheckMesh( TESSmesh *mesh ) } assert( f->prev == fPrev && f->anEdge == NULL ); + vPrev = vHead; for( vPrev = vHead ; (v = vPrev->next) != vHead; vPrev = v) { assert( v->prev == vPrev ); e = v->anEdge; @@ -822,6 +824,7 @@ void tessMeshCheckMesh( TESSmesh *mesh ) } assert( v->prev == vPrev && v->anEdge == NULL ); + ePrev = eHead; for( ePrev = eHead ; (e = ePrev->next) != eHead; ePrev = e) { assert( e->Sym->next == ePrev->Sym ); assert( e->Sym != e );