From: Chris Allegretta Date: Sun, 24 Mar 2002 00:46:22 +0000 (+0000) Subject: free_charptrarray, striponedir() - Plug some memory leaks (Steven Kneizys) X-Git-Tag: v1.0.9~9 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=7722edc56f054d443f2b2eb72a8d013b6b93844c;p=nano.git free_charptrarray, striponedir() - Plug some memory leaks (Steven Kneizys) git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_0_branch/nano@1139 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 5861eca3..aaf0819b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ CVS code - - files.c: + free_charptrarray, striponedir() + - Plug some memory leaks (Steven Kneizys). read_file() - Abort if we read a file of 0 lines (num_lines == 0), fixes BUG #70. - winio.c: diff --git a/files.c b/files.c index 7b156f54..722deaca 100644 --- a/files.c +++ b/files.c @@ -1085,7 +1085,7 @@ void free_charptrarray(char **array, int len) { int i; - for (i = 0; i < len - 1; i++) + for (i = 0; i < len; i++) free(array[i]); free(array); } @@ -1124,7 +1124,10 @@ void striponedir(char *foo) if (tmp != foo) *tmp = 0; else + { /* SPK may need to make a 'default' path here */ + if (*tmp != '/') *(tmp) = '.'; *(tmp+1) = 0; + } return; } @@ -1253,6 +1256,17 @@ char *do_browser(char *inpath) else path = mallocstrcpy(path, filelist[selected]); + /* SPK for '.' path, get the current path via getcwd */ + if (!strcmp(path, "./..")) { + free(path); + path = getcwd(NULL, 0); + striponedir(path); + align(&path); + free_charptrarray(filelist, numents); + free(foo); + return do_browser(path); + } + st = filestat(path); if (S_ISDIR(st.st_mode)) { if (opendir(path) == NULL) { @@ -1272,6 +1286,8 @@ char *do_browser(char *inpath) } /* Start over again with the new path value */ + free_charptrarray(filelist, numents); + free(foo); return do_browser(path); } else { retval = path;