Commit e9b5c6fe authored by Chris Allegretta's avatar Chris Allegretta
Browse files

- winio.c:browser_init(), striponedir(), do_browse_from() - Various memory...

- winio.c:browser_init(), striponedir(), do_browse_from() - Various memory leak fixes (David Benbennick)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1453 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 11 additions and 4 deletions
+11 -4
......@@ -52,6 +52,8 @@ CVS code
- Only goto_abort() if we *didnt* abort the command, making
the function seem horribly misnamed ;-) (David Benbennick).
- winio.c:
browser_init(), striponedir(), do_browse_from()
- Various memory leak fixes (David Benbennick).
do_yesno(), do_help()
- Add defined(NCURSES_MOUSE_VERSION) to macro so systems that
don't understand MEVENT will compile.
......
......@@ -2396,13 +2396,15 @@ void striponedir(char *foo)
{
char *tmp;
assert(foo != NULL);
/* Don't strip the root dir */
if (!strcmp(foo, "/"))
if (*foo == '\0' || strcmp(foo, "/") == 0)
return;
tmp = foo + strlen(foo);
tmp = foo + strlen(foo) - 1;
assert(tmp >= foo);
if (*tmp == '/')
tmp--;
*tmp = '\0';
while (*tmp != '/' && tmp != foo)
tmp--;
......@@ -2464,6 +2466,7 @@ char **browser_init(const char *path, int *longest, int *numents)
sprintf(filelist[i], "%s/%s", path, next->d_name);
i++;
}
closedir(dir);
if (*longest > COLS - 1)
*longest = COLS - 1;
......@@ -2841,8 +2844,10 @@ char *do_browse_from(const char *inpath)
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
striponedir(path);
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode))
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
free(path);
path = getcwd(NULL, PATH_MAX + 1);
}
}
#ifndef DISABLE_OPERATINGDIR
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment