Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1523 from emersion/set-same-selection-crash
Browse files Browse the repository at this point in the history
data-device: fix crash when setting the same selection twice
  • Loading branch information
ddevault authored Feb 1, 2019
2 parents 16a93ed + f1d3aef commit 28f11ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions types/data_device/wlr_data_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ static void seat_handle_selection_source_destroy(

void wlr_seat_set_selection(struct wlr_seat *seat,
struct wlr_data_source *source, uint32_t serial) {
if (seat->selection_source == source) {
seat->selection_serial = serial;
return;
}

if (seat->selection_source) {
wl_list_remove(&seat->selection_source_destroy.link);
wlr_data_source_destroy(seat->selection_source);
Expand Down
6 changes: 2 additions & 4 deletions types/wlr_primary_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ static void seat_handle_primary_selection_source_destroy(

void wlr_seat_set_primary_selection(struct wlr_seat *seat,
struct wlr_primary_selection_source *source, uint32_t serial) {
if (seat->primary_selection_source != NULL &&
seat->primary_selection_serial - serial < UINT32_MAX / 2) {
wlr_log(WLR_DEBUG, "Rejecting set_selection request, invalid serial "
"(%"PRIu32" <= %"PRIu32")", serial, seat->primary_selection_serial);
if (seat->primary_selection_source == source) {
seat->primary_selection_serial = serial;
return;
}

Expand Down

0 comments on commit 28f11ae

Please sign in to comment.