nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 706f01422dd5c6f12ca3d740f1bc64d20b8119c9
parent 6c0e5e3f2c4540dc96bde51ecc9ca2bf30270be4
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Mon, 15 Feb 2016 16:24:39 +0000

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

Diffstat:
MChangeLog | 2++
Msrc/files.c | 8+++-----
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -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 diff --git a/src/files.c b/src/files.c @@ -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) {