Commit 33a6f6a1 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

files: do not call free on the result of dirname

This fixes https://savannah.gnu.org/bugs/?47544,
and thus also http://gnats.netbsd.org/51010

.
Reported-by: default avatarAdrian Siekierka <asiekierka@gmail.com>
Reported-by: default avatarMatthew Hall <mhall@mhcomputing.net>
Signed-off-by: default avatarBenno Schulenberg <bensberg@justemail.net>
No related merge requests found
Showing with 3 additions and 7 deletions
+3 -7
......@@ -36,15 +36,11 @@
/* Verify that the containing directory of the given filename exists. */
bool has_valid_path(const char *filename)
{
char *parentdir;
char *namecopy = mallocstrcpy(NULL, filename);
char *parentdir = dirname(namecopy);
struct stat parentinfo;
bool validity = FALSE;
if (strrchr(filename, '/') == NULL)
parentdir = mallocstrcpy(NULL, ".");
else
parentdir = dirname(mallocstrcpy(NULL, filename));
if (stat(parentdir, &parentinfo) == -1) {
if (errno == ENOENT)
statusbar(_("Directory '%s' does not exist"), parentdir);
......@@ -59,7 +55,7 @@ bool has_valid_path(const char *filename)
validity = TRUE;
}
free(parentdir);
free(namecopy);
if (!validity)
beep();
......
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