From d3160ca4dbd561f45677d12598aafe2f1781ba72 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 17 Aug 2015 12:22:41 -0700 Subject: [PATCH] fixes #1907: skip MGLPolyline/MGLPolygons with zero points --- platform/ios/MGLMapView.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index db18ea012..53f60a951 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1828,6 +1828,10 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) if ([annotation isKindOfClass:[MGLMultiPoint class]]) { + NSUInteger count = [(MGLMultiPoint *)annotation pointCount]; + + if (count == 0) break; + CGFloat alpha = (delegateImplementsAlphaForShape ? [self.delegate mapView:self alphaForShapeAnnotation:annotation] : 1.0); @@ -1881,8 +1885,6 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) userInfo:nil] raise]; } - NSUInteger count = [(MGLMultiPoint *)annotation pointCount]; - CLLocationCoordinate2D *coordinates = (CLLocationCoordinate2D *)malloc(count * sizeof(CLLocationCoordinate2D)); [(MGLMultiPoint *)annotation getCoordinates:coordinates range:NSMakeRange(0, count)];