aboutsummaryrefslogtreecommitdiff
path: root/libbb/make_directory.c
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-08-24 19:07:31 +0000
committerMatt Kraai <kraai@debian.org>2001-08-24 19:07:31 +0000
commit2a953aed3831f8705444e720783ad4781904a625 (patch)
tree5895ebd0217363b1385ad24cfa099cbdea0a3648 /libbb/make_directory.c
parenta0065d5955133f0b20864e966dfc692fe41aed2b (diff)
downloadbusybox-w32-2a953aed3831f8705444e720783ad4781904a625.tar.gz
busybox-w32-2a953aed3831f8705444e720783ad4781904a625.tar.bz2
busybox-w32-2a953aed3831f8705444e720783ad4781904a625.zip
Fix a memory leak if parent directory creation failed.
Diffstat (limited to 'libbb/make_directory.c')
-rw-r--r--libbb/make_directory.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index 0a9d7b160..7b7fde911 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -49,16 +49,16 @@ int make_directory (char *path, long mode, int flags)
49 struct stat st; 49 struct stat st;
50 50
51 if (stat (path, &st) < 0 && errno == ENOENT) { 51 if (stat (path, &st) < 0 && errno == ENOENT) {
52 int status;
52 char *parent = dirname (path); 53 char *parent = dirname (path);
53 mode_t mask = umask (0); 54 mode_t mask = umask (0);
54 umask (mask); 55 umask (mask);
55 56
56 if (make_directory (parent, (0777 & ~mask) | 0300, 57 status = make_directory (parent, (0777 & ~mask) | 0300,
57 FILEUTILS_RECUR) < 0) 58 FILEUTILS_RECUR);
58 return -1;
59 free (parent); 59 free (parent);
60 60
61 if (make_directory (path, mode, 0) < 0) 61 if (status < 0 || make_directory (path, mode, 0) < 0)
62 return -1; 62 return -1;
63 } 63 }
64 } 64 }