selection: assert serial is non-zero before copying data to the clipboard

This commit is contained in:
Daniel Eklöf 2022-04-23 15:49:25 +02:00
parent 312f0dbcfd
commit 9c0f1a671c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -1533,6 +1533,8 @@ static const struct zwp_primary_selection_source_v1_listener primary_selection_s
bool
text_to_clipboard(struct seat *seat, struct terminal *term, char *text, uint32_t serial)
{
xassert(serial != 0);
struct wl_clipboard *clipboard = &seat->clipboard;
if (clipboard->data_source != NULL) {
@ -1568,7 +1570,6 @@ text_to_clipboard(struct seat *seat, struct terminal *term, char *text, uint32_t
wl_data_device_set_selection(seat->data_device, clipboard->data_source, serial);
/* Needed when sending the selection to other client */
xassert(serial != 0);
clipboard->serial = serial;
return true;
}
@ -1981,6 +1982,8 @@ text_to_primary(struct seat *seat, struct terminal *term, char *text, uint32_t s
if (term->wl->primary_selection_device_manager == NULL)
return false;
xassert(serial != 0);
struct wl_primary *primary = &seat->primary;
/* TODO: somehow share code with the clipboard equivalent */