From 6b9b6c0b0b6ccdfab883b602e9833ed2afab5109 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 2 Jul 2026 10:34:14 +0000 Subject: [PATCH] Copy UTF-8 data correctly. --- cmd-capture-pane.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index 75ab50867..febf29697 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -82,15 +82,16 @@ cmd_capture_pane_cell(struct screen *s, u_int xx, u_int yy) struct grid *gd = s->grid; struct hyperlinks *hl = s->hyperlinks; struct grid_cell gc; - char *line, *data, *tmp, *link, *linkid, *f, *b, *u; + char *line, *data, *link, *linkid, *f, *b, *u; + char c[UTF8_SIZE + 1]; const char *uri, *iid; u_int flags; grid_get_cell(gd, xx, yy, &gc); - tmp = utf8_tocstr(&gc.data); - utf8_stravis(&data, tmp, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL); - free(tmp); + memcpy(c, gc.data.data, gc.data.size); + c[gc.data.size] = '\0'; + utf8_stravis(&data, c, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL); if (gc.link != 0 && hyperlinks_get(hl, gc.link, &uri, &iid, NULL)) { xasprintf(&link, "%s", uri);