diff options
author | Matt Kraai | 2001-08-24 19:07:31 +0000 |
---|---|---|
committer | Matt Kraai | 2001-08-24 19:07:31 +0000 |
commit | 2a953aed3831f8705444e720783ad4781904a625 (patch) | |
tree | 5895ebd0217363b1385ad24cfa099cbdea0a3648 /libbb/make_directory.c | |
parent | a0065d5955133f0b20864e966dfc692fe41aed2b (diff) | |
download | busybox-2a953aed3831f8705444e720783ad4781904a625.zip busybox-2a953aed3831f8705444e720783ad4781904a625.tar.gz |
Fix a memory leak if parent directory creation failed.
Diffstat (limited to 'libbb/make_directory.c')
-rw-r--r-- | libbb/make_directory.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libbb/make_directory.c b/libbb/make_directory.c index 0a9d7b1..7b7fde9 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c @@ -49,16 +49,16 @@ int make_directory (char *path, long mode, int flags) struct stat st; if (stat (path, &st) < 0 && errno == ENOENT) { + int status; char *parent = dirname (path); mode_t mask = umask (0); umask (mask); - if (make_directory (parent, (0777 & ~mask) | 0300, - FILEUTILS_RECUR) < 0) - return -1; + status = make_directory (parent, (0777 & ~mask) | 0300, + FILEUTILS_RECUR); free (parent); - if (make_directory (path, mode, 0) < 0) + if (status < 0 || make_directory (path, mode, 0) < 0) return -1; } } |