From 1bf2023ed45f1bfcb8ac53d1d9d60dbc265d71e5 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 4 Aug 2025 13:16:13 +0000 Subject: [PATCH 1/2] Flush scrolling when wrapping so UTF-8 in last position draws correctly, GitHub issue 4518. --- screen-write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen-write.c b/screen-write.c index dce517f7..6f53dc17 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1901,7 +1901,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) log_debug("%s: wrapped at %u,%u", __func__, s->cx, s->cy); screen_write_linefeed(ctx, 1, 8); screen_write_set_cursor(ctx, 0, -1); - screen_write_collect_flush(ctx, 1, __func__); + screen_write_collect_flush(ctx, 0, __func__); } /* Sanity check cursor position. */ From 05b2893b9f3babac1b1fb67e1f79fe253927162a Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 4 Aug 2025 13:22:10 +0000 Subject: [PATCH 2/2] Do not leak buffer if not used, reported by someone in GitHub issue 4575. --- window-copy.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/window-copy.c b/window-copy.c index 809c2402..f93e548b 100644 --- a/window-copy.c +++ b/window-copy.c @@ -4887,6 +4887,8 @@ window_copy_copy_buffer(struct window_mode_entry *wme, const char *prefix, if (set_paste) paste_add(prefix, buf, len); + else + free(buf); } static void * @@ -4911,9 +4913,11 @@ static void window_copy_pipe(struct window_mode_entry *wme, struct session *s, const char *cmd) { + void *buf; size_t len; - window_copy_pipe_run(wme, s, cmd, &len); + buf = window_copy_pipe_run(wme, s, cmd, &len); + free (buf); } static void @@ -4924,9 +4928,10 @@ window_copy_copy_pipe(struct window_mode_entry *wme, struct session *s, size_t len; buf = window_copy_pipe_run(wme, s, cmd, &len); - if (buf != NULL) + if (buf != NULL) { window_copy_copy_buffer(wme, prefix, buf, len, set_paste, set_clip); + } } static void @@ -4937,9 +4942,10 @@ window_copy_copy_selection(struct window_mode_entry *wme, const char *prefix, size_t len; buf = window_copy_get_selection(wme, &len); - if (buf != NULL) + if (buf != NULL) { window_copy_copy_buffer(wme, prefix, buf, len, set_paste, set_clip); + } } static void