* 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
/* 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. */
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) {