From 8b6cccc5cc4ef084d32fa4fe302468753497bd66 Mon Sep 17 00:00:00 2001 From: Rocco Corsi Date: Tue, 2 Jan 2001 06:21:07 +0000 Subject: [PATCH] TAB-TAB completion segfaulting with more than 2048 files fixed. (Rocco) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@432 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ files.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 217393d6..08a3ca26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,8 +2,13 @@ CVS code - - faq.html: - Fix typos and small mistakes (Jordi). - files.c: + username_tab_completion() + - Added the (char *) sizeof when allocating memory for the filename + array (Rocco). cwd_tab_completion() - removed skipping . and .. when tabulating matches. + - Added the (char *) sizeof when allocating memory for the filename + array (Rocco). - nano.c: main() - Reorder the getopt options to be more or less alphabetical diff --git a/files.c b/files.c index 870be700..5d0c32e7 100644 --- a/files.c +++ b/files.c @@ -688,8 +688,8 @@ char **username_tab_completion(char *buf, int *num_matches) homedirs = (char **) NULL; *num_matches = 0; } - matches = nmalloc(BUFSIZ); - homedirs = nmalloc(BUFSIZ); + matches = nmalloc(BUFSIZ * sizeof(char *)); + homedirs = nmalloc(BUFSIZ * sizeof(char *)); strcat(buf, "*"); do { i = 0; @@ -757,7 +757,7 @@ char **cwd_tab_completion(char *buf, int *num_matches) DIR *dir; struct dirent *next; - matches = nmalloc(BUFSIZ); + matches = nmalloc(BUFSIZ * sizeof(char *)); /* Stick a wildcard onto the buf, for later use */ strcat(buf, "*"); -- 2.39.5