Commit 4e74030c authored by Peter K. Lee's avatar Peter K. Lee Committed by Commit Bot

Replaced casting with ObjCCastStrict<> to avoid crashes.

ObjCCastStrict<> returns nil if the object being casted is not of the
expected type. This offers a saner behavior when for whatever reasons
object is not of the expected type.

This is a workaround to avoid a growing crash in iOS 11.3 when an
object of UIView type is casted to one of CardView type. A later call
to -closeButtonFrame results in an exception (crash).

Bug: 393230
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I6a3f2b66c4ab6a8f268743e1ce8c902ccffaaa05
Reviewed-on: https://chromium-review.googlesource.com/1005562
Commit-Queue: Peter Lee <pkl@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549688}
parent 6915c5b2
...@@ -2292,8 +2292,11 @@ NSString* const kTransitionToolbarAnimationKey = ...@@ -2292,8 +2292,11 @@ NSString* const kTransitionToolbarAnimationKey =
cardView = card.view; cardView = card.view;
} else { } else {
// The recognizer is one of those attached to the card. // The recognizer is one of those attached to the card.
DCHECK([recognizer.view isKindOfClass:[CardView class]]); // See https://crbug.com/393230 where recognizer.view may not be a CardView
cardView = (CardView*)recognizer.view; // type. In that case, early return with a NO to avoid unnecessary crash.
cardView = base::mac::ObjCCastStrict<CardView>(recognizer.view);
if (!cardView)
return NO;
card = [self cardForView:cardView]; card = [self cardForView:cardView];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment