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: Adrian Siekierka <asiekierka@gmail.com> Reported-by: Matthew Hall <mhall@mhcomputing.net> Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Этот коммит содержится в:
родитель
284877104f
Коммит
33a6f6a1b6
10
src/files.c
10
src/files.c
@ -36,15 +36,11 @@
|
|||||||
/* Verify that the containing directory of the given filename exists. */
|
/* Verify that the containing directory of the given filename exists. */
|
||||||
bool has_valid_path(const char *filename)
|
bool has_valid_path(const char *filename)
|
||||||
{
|
{
|
||||||
char *parentdir;
|
char *namecopy = mallocstrcpy(NULL, filename);
|
||||||
|
char *parentdir = dirname(namecopy);
|
||||||
struct stat parentinfo;
|
struct stat parentinfo;
|
||||||
bool validity = FALSE;
|
bool validity = FALSE;
|
||||||
|
|
||||||
if (strrchr(filename, '/') == NULL)
|
|
||||||
parentdir = mallocstrcpy(NULL, ".");
|
|
||||||
else
|
|
||||||
parentdir = dirname(mallocstrcpy(NULL, filename));
|
|
||||||
|
|
||||||
if (stat(parentdir, &parentinfo) == -1) {
|
if (stat(parentdir, &parentinfo) == -1) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
statusbar(_("Directory '%s' does not exist"), parentdir);
|
statusbar(_("Directory '%s' does not exist"), parentdir);
|
||||||
@ -59,7 +55,7 @@ bool has_valid_path(const char *filename)
|
|||||||
validity = TRUE;
|
validity = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(parentdir);
|
free(namecopy);
|
||||||
|
|
||||||
if (!validity)
|
if (!validity)
|
||||||
beep();
|
beep();
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user