aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2019-02-24 09:24:58 +0100
committerDrew DeVault <sir@cmpwn.com>2019-02-24 19:40:10 -0500
commitd425206719467b8467f71118c08b253284c6ba09 (patch)
treea279f8b89390e8a642892c1b950c7bdb7aaef965
parent421283935b42ed889043cd06e590a61d8317e88c (diff)
data-device: check if there's a source before sending dnd_finish
This could cause a segfault in data_offer_destroy if the offer has version < 3.
-rw-r--r--types/data_device/wlr_data_offer.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/types/data_device/wlr_data_offer.c b/types/data_device/wlr_data_offer.c
index 086feb11..8246a9a2 100644
--- a/types/data_device/wlr_data_offer.c
+++ b/types/data_device/wlr_data_offer.c
@@ -96,7 +96,7 @@ static void data_offer_handle_receive(struct wl_client *client,
wlr_data_source_send(offer->source, mime_type, fd);
}
-static void data_offer_dnd_finish(struct wlr_data_offer *offer) {
+static void data_offer_source_dnd_finish(struct wlr_data_offer *offer) {
struct wlr_data_source *source = offer->source;
if (source->actions < 0) {
return;
@@ -142,7 +142,7 @@ static void data_offer_handle_finish(struct wl_client *client,
return;
}
- data_offer_dnd_finish(offer);
+ data_offer_source_dnd_finish(offer);
data_offer_destroy(offer);
}
@@ -190,14 +190,14 @@ void data_offer_destroy(struct wlr_data_offer *offer) {
wl_list_remove(&offer->source_destroy.link);
wl_list_remove(&offer->link);
- if (offer->type == WLR_DATA_OFFER_DRAG) {
+ if (offer->type == WLR_DATA_OFFER_DRAG && offer->source) {
// If the drag destination has version < 3, wl_data_offer.finish
// won't be called, so do this here as a safety net, because
// we still want the version >= 3 drag source to be happy.
if (wl_resource_get_version(offer->resource) <
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
- data_offer_dnd_finish(offer);
- } else if (offer->source && offer->source->impl->dnd_finish) {
+ data_offer_source_dnd_finish(offer);
+ } else if (offer->source->impl->dnd_finish) {
wlr_data_source_destroy(offer->source);
}
}