commit 2a5bd555e7f58f360428447eee4622f629dec7df
parent 7e1bc82d98ed73ec74bb61ec3c99e3679eaebbed
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 8 Aug 2015 08:10:57 +0000
Putting in the null byte "manually", and only when using UTF-8.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5347 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+2015-08-08 Benno Schulenberg <bensberg@justemail.net>
+ * 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-06 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main): For --enable-debug builds, let malloc() help
to find initialization failures and uses-after-free. Suggested by
diff --git 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);