From 499f019deaf6e7b7e7bb6bbb43b93a7296d9b4fe Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 9 Jun 2025 09:12:08 +0200 Subject: osc: 52: clear selection if the payload is the empty string --- osc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'osc.c') diff --git a/osc.c b/osc.c index d59adc5a..834029c1 100644 --- a/osc.c +++ b/osc.c @@ -73,16 +73,19 @@ osc_to_clipboard(struct terminal *term, const char *target, } char *decoded = base64_decode(base64_data, NULL); - if (decoded == NULL) { - if (errno == EINVAL) - LOG_WARN("OSC: invalid clipboard data: %s", base64_data); - else - LOG_ERRNO("base64_decode() failed"); + if (decoded == NULL || decoded[0] == '\0') { + if (decoded == NULL) { + if (errno == EINVAL) + LOG_WARN("OSC: invalid clipboard data: %s", base64_data); + else + LOG_ERRNO("base64_decode() failed"); + } if (to_clipboard) selection_clipboard_unset(seat); if (to_primary) selection_primary_unset(seat); + free(decoded); return; } -- cgit v1.3