From 2f4e2837e5f2be1a9e9440ba6317220a6cd8f918 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 30 Jan 2026 09:30:37 +0100 Subject: [PATCH] Wayland paste and DnD: fix minor issue revealed by valgrind. --- src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx index 743daef07..edf700c96 100644 --- a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx +++ b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx @@ -406,15 +406,14 @@ static void get_clipboard_or_dragged_text(struct wl_data_offer *offer) { fl_selection_buffer_length[1] = rest+1000; } from = fl_selection_buffer[1]; - while (true) { + while (rest > 0) { ssize_t n = read(fds[0], from, rest); - if (n <= 0) { - close(fds[0]); - break; - } + if (n <= 0) break; n = Fl_Screen_Driver::convert_crlf(from, n); from += n; + rest -= n; } + close(fds[0]); fl_selection_length[1] = from - fl_selection_buffer[1]; fl_selection_buffer[1][fl_selection_length[1]] = 0; way_out: