From 9c0f1a671cb015b650f7ed80e8fcf66d07c9e87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 23 Apr 2022 15:49:25 +0200 Subject: [PATCH] selection: assert serial is non-zero before copying data to the clipboard --- selection.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/selection.c b/selection.c index da62d354..8a18c6bb 100644 --- a/selection.c +++ b/selection.c @@ -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 */