| Index: ios/web/web_state/ui/crw_web_controller.mm
|
| diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
|
| index 19a95a60e53e49fa95a2123711e9f9f759feb4a8..c695bf76f977afd25079aba11cdf90c0ca095d15 100644
|
| --- a/ios/web/web_state/ui/crw_web_controller.mm
|
| +++ b/ios/web/web_state/ui/crw_web_controller.mm
|
| @@ -2164,6 +2164,14 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
|
| [self webWillFinishHistoryNavigationFromEntry:fromEntry];
|
| [self updateHTML5HistoryState];
|
| } else {
|
| + // TODO(crbug.com/691492): After discardNonCommittedItems, the item
|
| + // pointed by |fromEntry| may not be valid anymore.
|
| + // Set |fromEntry| to nil to avoid crash whan using the item.
|
| + // Remove when the fix is not needed anymore.
|
| + if ([fromEntry isEqual:sessionController.transientEntry] ||
|
| + [fromEntry isEqual:sessionController.pendingEntry]) {
|
| + fromEntry = nil;
|
| + }
|
| [sessionController discardNonCommittedItems];
|
| [sessionController setPendingItemIndex:index];
|
|
|
| @@ -2401,7 +2409,10 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
|
| }
|
|
|
| - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry {
|
| - DCHECK(fromEntry);
|
| + // TODO(crbug.com/691492): Removing the DCHECK as |fromEntry| may be nil if
|
| + // the pending entry was discarded.
|
| + // Remove when the fix is not needed anymore.
|
| + // DCHECK(fromEntry);
|
| [self updateDesktopUserAgentForEntry:self.currentSessionEntry
|
| fromEntry:fromEntry];
|
| [_delegate webWillFinishHistoryNavigationFromEntry:fromEntry];
|
|
|