- 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-d3aeb78583b8master
parent
d127c71ab3
commit
e9b5c6fe90
|
@ -52,6 +52,8 @@ CVS code
|
||||||
- Only goto_abort() if we *didnt* abort the command, making
|
- Only goto_abort() if we *didnt* abort the command, making
|
||||||
the function seem horribly misnamed ;-) (David Benbennick).
|
the function seem horribly misnamed ;-) (David Benbennick).
|
||||||
- winio.c:
|
- winio.c:
|
||||||
|
browser_init(), striponedir(), do_browse_from()
|
||||||
|
- Various memory leak fixes (David Benbennick).
|
||||||
do_yesno(), do_help()
|
do_yesno(), do_help()
|
||||||
- Add defined(NCURSES_MOUSE_VERSION) to macro so systems that
|
- Add defined(NCURSES_MOUSE_VERSION) to macro so systems that
|
||||||
don't understand MEVENT will compile.
|
don't understand MEVENT will compile.
|
||||||
|
|
13
files.c
13
files.c
|
@ -2396,13 +2396,15 @@ void striponedir(char *foo)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
|
assert(foo != NULL);
|
||||||
/* Don't strip the root dir */
|
/* Don't strip the root dir */
|
||||||
if (!strcmp(foo, "/"))
|
if (*foo == '\0' || strcmp(foo, "/") == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tmp = foo + strlen(foo);
|
tmp = foo + strlen(foo) - 1;
|
||||||
|
assert(tmp >= foo);
|
||||||
if (*tmp == '/')
|
if (*tmp == '/')
|
||||||
tmp--;
|
*tmp = '\0';
|
||||||
|
|
||||||
while (*tmp != '/' && tmp != foo)
|
while (*tmp != '/' && tmp != foo)
|
||||||
tmp--;
|
tmp--;
|
||||||
|
@ -2464,6 +2466,7 @@ char **browser_init(const char *path, int *longest, int *numents)
|
||||||
sprintf(filelist[i], "%s/%s", path, next->d_name);
|
sprintf(filelist[i], "%s/%s", path, next->d_name);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
closedir(dir);
|
||||||
|
|
||||||
if (*longest > COLS - 1)
|
if (*longest > COLS - 1)
|
||||||
*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)) {
|
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
||||||
striponedir(path);
|
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);
|
path = getcwd(NULL, PATH_MAX + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
|
|
Loading…
Reference in New Issue