aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-12-28 10:25:03 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-12-28 10:25:03 +0100
commit2272129a93d9492a42ef43987f829940d26dc862 (patch)
treee80a4341b5c8290f6ee9d46cd966b1a3805834b8
parent8578196b763a70746f2ab17170eb7ca9399ab8ac (diff)
downloadbusybox-w32-2272129a93d9492a42ef43987f829940d26dc862.tar.gz
busybox-w32-2272129a93d9492a42ef43987f829940d26dc862.tar.bz2
busybox-w32-2272129a93d9492a42ef43987f829940d26dc862.zip
plug a DIR* leak on error path
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/find_root_device.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c
index 32c86cea8..8436cd664 100644
--- a/libbb/find_root_device.c
+++ b/libbb/find_root_device.c
@@ -29,14 +29,15 @@ static char *find_block_device_in_dir(struct arena *ap)
29 char *retpath = NULL; 29 char *retpath = NULL;
30 int len, rem; 30 int len, rem;
31 31
32 dir = opendir(ap->devpath);
33 if (!dir)
34 return NULL;
35
36 len = strlen(ap->devpath); 32 len = strlen(ap->devpath);
37 rem = DEVNAME_MAX-2 - len; 33 rem = DEVNAME_MAX-2 - len;
38 if (rem <= 0) 34 if (rem <= 0)
39 return NULL; 35 return NULL;
36
37 dir = opendir(ap->devpath);
38 if (!dir)
39 return NULL;
40
40 ap->devpath[len++] = '/'; 41 ap->devpath[len++] = '/';
41 42
42 while ((entry = readdir(dir)) != NULL) { 43 while ((entry = readdir(dir)) != NULL) {