forked from 12to11/12to11
Improve serial wraparound checking
* data_device.c (SetSelection): * primary_selection.c (SetSelection): Handle selection serial wraparound.
This commit is contained in:
parent
c90af69ecd
commit
be117ac93d
2 changed files with 8 additions and 2 deletions
|
@ -1005,7 +1005,11 @@ SetSelection (struct wl_client *client, struct wl_resource *resource,
|
||||||
client, wl_resource_get_id (source_resource), serial);
|
client, wl_resource_get_id (source_resource), serial);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (serial < last_selection_change_serial)
|
/* Note that both serial and last_selection_change_serial are
|
||||||
|
unsigned. Remember two's complement arithmetic. -1 is
|
||||||
|
0xffffffff, while -4294967295 overflows twice and is
|
||||||
|
0x00000001. */
|
||||||
|
if (serial - last_selection_change_serial > UINT32_MAX / 2)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf (stderr, "wl_client@%p could not set the selection, "
|
fprintf (stderr, "wl_client@%p could not set the selection, "
|
||||||
|
|
|
@ -512,7 +512,9 @@ SetSelection (struct wl_client *client, struct wl_resource *resource,
|
||||||
/* This device is inert, since the seat has been deleted. */
|
/* This device is inert, since the seat has been deleted. */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (serial < last_change_serial)
|
/* Note that both serial and last_change_serial are unsigned.
|
||||||
|
Remember two's complement arithmetic. */
|
||||||
|
if (serial - last_change_serial > UINT32_MAX / 2)
|
||||||
/* This change is out of date. Do nothing. */
|
/* This change is out of date. Do nothing. */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue