mirror of git://git.sv.gnu.org/nano.git
Avoiding the loss a buffer when getcwd() fails.
This fixes Savannah bug #47129 reported by Mike Frysinger. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5647 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
6c0e5e3f2c
commit
706f01422d
|
@ -2,6 +2,8 @@
|
|||
* src/files.c (read_file): Free not just the struct but also the
|
||||
data it contains, and also when it is the first and only line.
|
||||
This fixes Savannah bug #47153 reported by Mike Frysinger.
|
||||
* src/files.c (get_full_path): Avoid losing a buffer when getcwd()
|
||||
fails. This fixes Savannah bug #47129 reported by Mike Frysinger.
|
||||
|
||||
2016-02-14 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/search.c (do_replace_loop): Make iterating through replacement
|
||||
|
|
|
@ -1413,14 +1413,13 @@ char *get_full_path(const char *origpath)
|
|||
/* Get the current directory. If it doesn't exist, back up and try
|
||||
* again until we get a directory that does, and use that as the
|
||||
* current directory. */
|
||||
d_here = charalloc(PATH_MAX + 1);
|
||||
d_here = getcwd(d_here, PATH_MAX + 1);
|
||||
d_here = getcwd(NULL, PATH_MAX + 1);
|
||||
|
||||
while (d_here == NULL) {
|
||||
if (chdir("..") == -1)
|
||||
break;
|
||||
|
||||
d_here = getcwd(d_here, PATH_MAX + 1);
|
||||
d_here = getcwd(NULL, PATH_MAX + 1);
|
||||
}
|
||||
|
||||
/* If we succeeded, canonicalize it in d_here. */
|
||||
|
@ -1481,8 +1480,7 @@ char *get_full_path(const char *origpath)
|
|||
free(d_there);
|
||||
|
||||
/* Get the full path. */
|
||||
d_there = charalloc(PATH_MAX + 1);
|
||||
d_there = getcwd(d_there, PATH_MAX + 1);
|
||||
d_there = getcwd(NULL, PATH_MAX + 1);
|
||||
|
||||
/* If we succeeded, canonicalize it in d_there. */
|
||||
if (d_there != NULL) {
|
||||
|
|
Loading…
Reference in New Issue