mirror of
https://github.com/sheumann/hush.git
synced 2024-12-27 16:31:24 +00:00
Fix a memory leak if parent directory creation failed.
This commit is contained in:
parent
a0065d5955
commit
2a953aed38
@ -49,16 +49,16 @@ int make_directory (char *path, long mode, int flags)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat (path, &st) < 0 && errno == ENOENT) {
|
if (stat (path, &st) < 0 && errno == ENOENT) {
|
||||||
|
int status;
|
||||||
char *parent = dirname (path);
|
char *parent = dirname (path);
|
||||||
mode_t mask = umask (0);
|
mode_t mask = umask (0);
|
||||||
umask (mask);
|
umask (mask);
|
||||||
|
|
||||||
if (make_directory (parent, (0777 & ~mask) | 0300,
|
status = make_directory (parent, (0777 & ~mask) | 0300,
|
||||||
FILEUTILS_RECUR) < 0)
|
FILEUTILS_RECUR);
|
||||||
return -1;
|
|
||||||
free (parent);
|
free (parent);
|
||||||
|
|
||||||
if (make_directory (path, mode, 0) < 0)
|
if (status < 0 || make_directory (path, mode, 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user