From 75e73ce2e351a6c9d51e6bfcc3c1625dc434ba8a Mon Sep 17 00:00:00 2001 From: kraai Date: Fri, 24 Aug 2001 19:07:31 +0000 Subject: Fix a memory leak if parent directory creation failed. git-svn-id: svn://busybox.net/trunk/busybox@3349 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- libbb/make_directory.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libbb') 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) 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; } } -- cgit v1.2.3-55-g6feb