Commit 6e50c5a3 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Fix crash in media::UserInputMonitorLinuxCore::DispatchXEvent

The X server may send unsolicited events (from clients calling
XSendEvent() or from new keyboard mappings).  So we must check that
the event is the correct type before dispatching it.

R=dalecurtis

Change-Id: Ic3e19f7da1415c358991609c9b016bd60ead2038
Bug: 1140927
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490674
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819650}
parent ade30687
......@@ -115,9 +115,10 @@ void UserInputMonitorLinuxCore::DispatchXEvent(x11::Event* event) {
DCHECK(io_task_runner_->BelongsToCurrentThread());
auto* raw = event->As<x11::Input::RawDeviceEvent>();
DCHECK(raw);
DCHECK(raw->opcode == x11::Input::RawDeviceEvent::RawKeyPress ||
raw->opcode == x11::Input::RawDeviceEvent::RawKeyRelease);
if (!raw || (raw->opcode != x11::Input::RawDeviceEvent::RawKeyPress &&
raw->opcode != x11::Input::RawDeviceEvent::RawKeyRelease)) {
return;
}
ui::EventType type = raw->opcode == x11::Input::RawDeviceEvent::RawKeyPress
? ui::ET_KEY_PRESSED
......
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