Commit f14a92f7 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Make DropTargetEvent copyable.

This is necessary for creating modified DropTargetEvents (e.g. if you need to
make a provided const event& relative to a new parent).

The primary concern here is |data_|, which is a reference member.  Copying a
DropTargetEvent shallow-copies this reference rather than deep-copying it, so
the lifetime of the copied event must not extend past that of the data that was
used to construct the original event.  I'm concerned that this change makes it
easier for people to cause UAFs; however, that concern already existed with the
original object, and the right fix is probably not to prevent copying but to
make DropTargetEvent not keep |data_| by reference to begin with.  That's a more
involved change than I have the scope to do for now.

Bug: 923188
Change-Id: I35d475081584577cc0217f672a45b5a9e5a60a4e
Reviewed-on: https://chromium-review.googlesource.com/c/1483673
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634864}
parent 292c7a74
...@@ -23,5 +23,10 @@ DropTargetEvent::DropTargetEvent(const OSExchangeData& data, ...@@ -23,5 +23,10 @@ DropTargetEvent::DropTargetEvent(const OSExchangeData& data,
data_(data), data_(data),
source_operations_(source_operations) {} source_operations_(source_operations) {}
DropTargetEvent::DropTargetEvent(const DropTargetEvent& other)
: LocatedEvent(other),
data_(other.data_),
source_operations_(other.source_operations_) {}
} // namespace ui } // namespace ui
...@@ -11,12 +11,15 @@ ...@@ -11,12 +11,15 @@
namespace ui { namespace ui {
// Note: This object must not outlive the OSExchangeData used to construct it,
// as it stores that by reference.
class UI_BASE_EXPORT DropTargetEvent : public LocatedEvent { class UI_BASE_EXPORT DropTargetEvent : public LocatedEvent {
public: public:
DropTargetEvent(const OSExchangeData& data, DropTargetEvent(const OSExchangeData& data,
const gfx::PointF& location, const gfx::PointF& location,
const gfx::PointF& root_location, const gfx::PointF& root_location,
int source_operations); int source_operations);
DropTargetEvent(const DropTargetEvent& other);
const OSExchangeData& data() const { return data_; } const OSExchangeData& data() const { return data_; }
int source_operations() const { return source_operations_; } int source_operations() const { return source_operations_; }
...@@ -27,8 +30,6 @@ class UI_BASE_EXPORT DropTargetEvent : public LocatedEvent { ...@@ -27,8 +30,6 @@ class UI_BASE_EXPORT DropTargetEvent : public LocatedEvent {
// Bitmask of supported DragDropTypes::DragOperation by the source. // Bitmask of supported DragDropTypes::DragOperation by the source.
int source_operations_; int source_operations_;
DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
}; };
} // namespace ui } // namespace ui
......
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