diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index db18ea01281..53f60a95181 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1828,6 +1828,10 @@ - (void)addAnnotations:(NS_ARRAY_OF(id ) *)annotations 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 @@ - (void)addAnnotations:(NS_ARRAY_OF(id ) *)annotations userInfo:nil] raise]; } - NSUInteger count = [(MGLMultiPoint *)annotation pointCount]; - CLLocationCoordinate2D *coordinates = (CLLocationCoordinate2D *)malloc(count * sizeof(CLLocationCoordinate2D)); [(MGLMultiPoint *)annotation getCoordinates:coordinates range:NSMakeRange(0, count)];