From 567d47168132ae9c072ec160e066260e33241c1b Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Wed, 5 Jul 2006 05:31:21 +0000
Subject: [PATCH] in display_string(), properly handle buf[start_index]'s being
 a null terminator

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3749 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 4 ++++
 src/winio.c | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 82c2db5e..a777f9a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,6 +51,10 @@ CVS code -
 - help.c:
   do_help()
 	- Simplify screen update handling and exiting. (DLR)
+- winio.c:
+  display_string()
+	- Properly handle buf[start_index]'s being a null terminator.
+	  (DLR)
 - doc/syntax/c.nanorc:
 	- Since .i and .ii are preprocessed C and C++ output, colorize
 	  them here. (Mike Frysinger)
diff --git a/src/winio.c b/src/winio.c
index a95be19b..a19e1008 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -1809,8 +1809,8 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
 
     index = 0;
 
-    if (buf[start_index] != '\t' && (column < start_col || (dollars &&
-	column > 0))) {
+    if (buf[start_index] != '\0' && buf[start_index] != '\t' &&
+	(column < start_col || (dollars && column > 0))) {
 	/* We don't display all of buf[start_index] since it starts to
 	 * the left of the screen. */
 	buf_mb_len = parse_mbchar(buf + start_index, buf_mb, NULL);
-- 
GitLab