From 4058709e0bd96b2d86f52d826b9786021b880f81 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Tue, 16 Jan 2001 04:45:38 +0000
Subject: [PATCH] input_tab(): Added memset() to matchBuf to ensure sanity
 (Rocco, Adam).

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

diff --git a/ChangeLog b/ChangeLog
index d8e010c6..2016a67a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,7 +28,7 @@ General
 	- Added space and - keys to do page up and down.
   cwd_tab_completion(), input_tab()
 	- Changed bare malloc/calloc calls to nmalloc (found by Rocco).
-	- Added zero end of tmpBuf for sanity (Rocco).
+	- Added memset() to matchBuf to ensure sanity (Rocco, Adam).
 - nano.c:
   ABCD()
 	- New function, figures out what kbinput to return given
diff --git a/files.c b/files.c
index 6b5a9d2b..8eef1e26 100644
--- a/files.c
+++ b/files.c
@@ -883,9 +883,9 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
 	/* Make a local copy of the string -- up to the position of the
 	   cursor */
 	matchBuf = (char *) nmalloc((strlen(buf) + 2) * sizeof(char));
+	memset(matchBuf, '\0', (strlen(buf) + 2));
 
 	strncpy(matchBuf, buf, place);
-	matchBuf[place] = 0;
 	tmp = matchBuf;
 
 	/* skip any leading white space */
-- 
GitLab