Commit 0792afed authored by David Bokan's avatar David Bokan Committed by Commit Bot

Fix crash in Optional.value()

This was introduced in https://crrev.com/c/2142514 when the invalid
value being case to an EventDisposition enum was turned into a
base::Optional de-ref. This situation should never occur but the crashes
indicate it does.

This CL preverves old behavior to prevent the crash.

TBR=nzolghadr@chromium.org

Bug: 1069760
Change-Id: I412edf2bff202d68730a3374792f1dab16a91426
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145567
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758268}
parent 5c98faff
...@@ -809,17 +809,21 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( ...@@ -809,17 +809,21 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
// Noncancellable wheel events should have phase info. // Noncancellable wheel events should have phase info.
DCHECK(wheel_event.phase != WebMouseWheelEvent::kPhaseNone || DCHECK(wheel_event.phase != WebMouseWheelEvent::kPhaseNone ||
wheel_event.momentum_phase != WebMouseWheelEvent::kPhaseNone); wheel_event.momentum_phase != WebMouseWheelEvent::kPhaseNone);
DCHECK(mouse_wheel_result_.has_value());
result = mouse_wheel_result_.value();
if (wheel_event.phase == WebMouseWheelEvent::kPhaseEnded || DCHECK(mouse_wheel_result_.has_value());
wheel_event.phase == WebMouseWheelEvent::kPhaseCancelled || // TODO(bokan): This should never happen but after changing
wheel_event.momentum_phase == WebMouseWheelEvent::kPhaseEnded || // mouse_event_result_ to a base::Optional, crashes indicate that it does
wheel_event.momentum_phase == WebMouseWheelEvent::kPhaseCancelled) { // so |if| maintains prior behavior. https://crbug.com/1069760.
mouse_wheel_result_.reset(); if (mouse_wheel_result_.has_value()) {
} else { result = mouse_wheel_result_.value();
return result; if (wheel_event.phase == WebMouseWheelEvent::kPhaseEnded ||
wheel_event.phase == WebMouseWheelEvent::kPhaseCancelled ||
wheel_event.momentum_phase == WebMouseWheelEvent::kPhaseEnded ||
wheel_event.momentum_phase == WebMouseWheelEvent::kPhaseCancelled) {
mouse_wheel_result_.reset();
} else {
return result;
}
} }
} }
......
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