Commit e23c00ee authored by David Munro's avatar David Munro Committed by Commit Bot

exo: Fix a nullptr dereference

In some cases (e.g. the linked bug) source can be null. SetSelection is
already a no-op for nullptr source (and invalid for nullptr data_device)
so there's no change in behaviour for the case where event_type !=
nullopt, and it fixes a nullptr dereference when event_type == nullopt.

Bug: 1138761
Test: Deploy, launch evolution, Chrome doesn't crash
Change-Id: I23da80e418834f5c1e38eecd2f0b140638b63a8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2487022Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarDaichi Hirono <hirono@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarFergus Dall <sidereal@google.com>
Commit-Queue: David Munro <davidmunro@google.com>
Cr-Commit-Position: refs/heads/master@{#820056}
parent 33ed77d6
...@@ -306,21 +306,27 @@ class WaylandDataDeviceDelegate : public DataDeviceDelegate { ...@@ -306,21 +306,27 @@ class WaylandDataDeviceDelegate : public DataDeviceDelegate {
serial_tracker_->GetEventType(serial); serial_tracker_->GetEventType(serial);
if (event_type == base::nullopt) { if (event_type == base::nullopt) {
LOG(ERROR) << "The serial passed to StartDrag does not exist."; LOG(ERROR) << "The serial passed to StartDrag does not exist.";
source->Cancelled(); if (source) {
source->Cancelled();
}
return; return;
} }
if (event_type == wayland::SerialTracker::EventType::POINTER_BUTTON_DOWN && if (event_type == wayland::SerialTracker::EventType::POINTER_BUTTON_DOWN &&
serial_tracker_->GetPointerDownSerial() == serial) { serial_tracker_->GetPointerDownSerial() == serial) {
DCHECK(data_device);
data_device->StartDrag(source, origin, icon, data_device->StartDrag(source, origin, icon,
ui::mojom::DragEventSource::kMouse); ui::mojom::DragEventSource::kMouse);
} else if (event_type == wayland::SerialTracker::EventType::TOUCH_DOWN && } else if (event_type == wayland::SerialTracker::EventType::TOUCH_DOWN &&
serial_tracker_->GetTouchDownSerial() == serial) { serial_tracker_->GetTouchDownSerial() == serial) {
DCHECK(data_device);
data_device->StartDrag(source, origin, icon, data_device->StartDrag(source, origin, icon,
ui::mojom::DragEventSource::kTouch); ui::mojom::DragEventSource::kTouch);
} else { } else {
LOG(ERROR) << "The serial passed to StartDrag does not match its " LOG(ERROR) << "The serial passed to StartDrag does not match its "
"expected types."; "expected types.";
source->Cancelled(); if (source) {
source->Cancelled();
}
} }
} }
...@@ -331,9 +337,12 @@ class WaylandDataDeviceDelegate : public DataDeviceDelegate { ...@@ -331,9 +337,12 @@ class WaylandDataDeviceDelegate : public DataDeviceDelegate {
serial_tracker_->GetEventType(serial); serial_tracker_->GetEventType(serial);
if (event_type == base::nullopt) { if (event_type == base::nullopt) {
LOG(ERROR) << "The serial passed to SetSelection does not exist."; LOG(ERROR) << "The serial passed to SetSelection does not exist.";
source->Cancelled(); if (source) {
source->Cancelled();
}
return; return;
} }
DCHECK(data_device);
data_device->SetSelection(source); data_device->SetSelection(source);
} }
......
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