data-device: fix crash when setting the same selection twice

This commit is contained in:
emersion 2019-01-31 20:33:48 +01:00
parent 41af8d8459
commit f1d3aeff9a
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 7 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}