From 3cdf6ff1de6f446a3103d91e1122cec8df78c79b Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Sat, 8 Feb 2003 02:02:02 +0000
Subject: [PATCH] - files.c:input_tab() - Fix assumption that matches is null
 terminated (David Benbennick)

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

diff --git a/ChangeLog b/ChangeLog
index f5d94187..af47f8f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@ CVS code
 	- Translation updates (see po/ChangeLog for details).
 	- Fix globals and externs such that nano will compile with
 	  DISABLE_SPELLER (David Benbennick).
+- files.c:
+  intput_tab()
+	- Fix assumption that matches is null terminated (David 
+	  Benbennick).
 - nano.c:
   main()
 	- Fix nano not compiling with ENABLE_RCFILE and DISABLE_TABCOMP
diff --git a/files.c b/files.c
index 6580db66..2dfa1b60 100644
--- a/files.c
+++ b/files.c
@@ -2116,6 +2116,8 @@ char **cwd_tab_completion(char *buf, int *num_matches)
 		break;
 	}
     }
+    closedir(dir);
+    free(dirname);
 
     return matches;
 }
@@ -2312,7 +2314,7 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list)
 
 		/* And if the next match isn't going to fit on the
 		   line, move to the next one */
-		if (col > (COLS - longestname) && matches[i + 1] != NULL) {
+		if (col > COLS - longestname && i + 1 < num_matches) {
 		    editline++;
 		    wmove(edit, editline, 0);
 		    if (editline == editwinrows - 1) {
-- 
GitLab