From 03d10bb67a72153e1aca0e7c67eaf022769d75b9 Mon Sep 17 00:00:00 2001 From: Jesse Bounds Date: Fri, 7 Apr 2017 15:23:39 -0700 Subject: [ios, macos] Guard against looking up annotation contexts MGLAnnotationTagNotFound (#8686) --- platform/macos/src/MGLMapView.mm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'platform/macos/src') diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index a5a5c53df3..a873d9ef82 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -1796,10 +1796,12 @@ public: for (auto const& annotationTag: annotationTags) { - if (!_annotationContextsByAnnotationTag.count(annotationTag)) + if (!_annotationContextsByAnnotationTag.count(annotationTag) || + annotationTag == MGLAnnotationTagNotFound) { continue; } + MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); NSAssert(annotationContext.annotation, @"Missing annotation for tag %u.", annotationTag); if (annotationContext.annotation) @@ -1816,7 +1818,8 @@ public: /// Returns the annotation assigned the given tag. Cheap. - (id )annotationWithTag:(MGLAnnotationTag)tag { - if (!_annotationContextsByAnnotationTag.count(tag)) { + if ( ! _annotationContextsByAnnotationTag.count(tag) || + tag == MGLAnnotationTagNotFound) { return nil; } @@ -2147,9 +2150,11 @@ public: } - (id )selectedAnnotation { - if (!_annotationContextsByAnnotationTag.count(_selectedAnnotationTag)) { + if ( ! _annotationContextsByAnnotationTag.count(_selectedAnnotationTag) || + _selectedAnnotationTag == MGLAnnotationTagNotFound) { return nil; } + MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(_selectedAnnotationTag); return annotationContext.annotation; } -- cgit v1.2.1