Fix array bounds crash in MapView
Summary: Under some circumstances, the calloutIndex might be > number of callout views, (possibly due to a race condition?). This prevents that from crashing. Reviewed By: tadeuzagallo Differential Revision: D3196010 fb-gh-sync-id: 6485e64c682937431cb8598d7f3f42e8d37eeff1 fbshipit-source-id: 6485e64c682937431cb8598d7f3f42e8d37eeff1
This commit is contained in:
parent
e9398c7926
commit
546d140ec7
|
@ -226,7 +226,8 @@ RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, RCTMap)
|
||||||
}
|
}
|
||||||
annotationView.canShowCallout = (annotation.title.length > 0);
|
annotationView.canShowCallout = (annotation.title.length > 0);
|
||||||
|
|
||||||
if (annotation.leftCalloutViewIndex != NSNotFound) {
|
if (annotation.leftCalloutViewIndex != NSNotFound &&
|
||||||
|
annotation.leftCalloutViewIndex < mapView.reactSubviews.count) {
|
||||||
annotationView.leftCalloutAccessoryView =
|
annotationView.leftCalloutAccessoryView =
|
||||||
mapView.reactSubviews[annotation.leftCalloutViewIndex];
|
mapView.reactSubviews[annotation.leftCalloutViewIndex];
|
||||||
} else if (annotation.hasLeftCallout) {
|
} else if (annotation.hasLeftCallout) {
|
||||||
|
@ -236,7 +237,8 @@ RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, RCTMap)
|
||||||
annotationView.leftCalloutAccessoryView = nil;
|
annotationView.leftCalloutAccessoryView = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (annotation.rightCalloutViewIndex != NSNotFound) {
|
if (annotation.rightCalloutViewIndex != NSNotFound &&
|
||||||
|
annotation.rightCalloutViewIndex < mapView.reactSubviews.count) {
|
||||||
annotationView.rightCalloutAccessoryView =
|
annotationView.rightCalloutAccessoryView =
|
||||||
mapView.reactSubviews[annotation.rightCalloutViewIndex];
|
mapView.reactSubviews[annotation.rightCalloutViewIndex];
|
||||||
} else if (annotation.hasRightCallout) {
|
} else if (annotation.hasRightCallout) {
|
||||||
|
@ -248,7 +250,8 @@ RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, RCTMap)
|
||||||
|
|
||||||
//http://stackoverflow.com/questions/32581049/mapkit-ios-9-detailcalloutaccessoryview-usage
|
//http://stackoverflow.com/questions/32581049/mapkit-ios-9-detailcalloutaccessoryview-usage
|
||||||
if ([annotationView respondsToSelector:@selector(detailCalloutAccessoryView)]) {
|
if ([annotationView respondsToSelector:@selector(detailCalloutAccessoryView)]) {
|
||||||
if (annotation.detailCalloutViewIndex != NSNotFound) {
|
if (annotation.detailCalloutViewIndex != NSNotFound &&
|
||||||
|
annotation.detailCalloutViewIndex < mapView.reactSubviews.count) {
|
||||||
UIView *calloutView = mapView.reactSubviews[annotation.detailCalloutViewIndex];
|
UIView *calloutView = mapView.reactSubviews[annotation.detailCalloutViewIndex];
|
||||||
NSLayoutConstraint *widthConstraint =
|
NSLayoutConstraint *widthConstraint =
|
||||||
[NSLayoutConstraint constraintWithItem:calloutView
|
[NSLayoutConstraint constraintWithItem:calloutView
|
||||||
|
|
Loading…
Reference in New Issue