From c67821677004407d98242d34ec62dacbf5634b43 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Sun, 15 Nov 2015 06:46:03 +0000 Subject: [PATCH] Backport r5347 from trunk. git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_4_branch@5413 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/winio.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 97250dc2..cc98a421 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-08-08 Benno Schulenberg + * src/winio.c (display_string): For some reason the reallocation done + by null_at() messes things up. So put in the null byte "manually". + This is a fix -- or workaround -- for Savannah bug #45718. + 2015-08-03 Benno Schulenberg * src/rcfile.c (parse_binding): Check the value of shortcut->toggle only if it actually is a toggle. Found with valgrind. diff --git a/src/winio.c b/src/winio.c index 614d0746..af269010 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1999,10 +1999,13 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool char *nctrl_buf_mb = charalloc(mb_cur_max()); int nctrl_buf_mb_len, i; +#ifdef ENABLE_UTF8 /* Make sure an invalid sequence-starter byte is properly * terminated, so that it doesn't pick up lingering bytes * of any previous content. */ - null_at(&buf_mb, buf_mb_len); + if (using_utf8() && buf_mb_len == 1) + buf_mb[1] = '\0'; +#endif nctrl_buf_mb = mbrep(buf_mb, nctrl_buf_mb, &nctrl_buf_mb_len); -- 2.39.5