summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-12-28 09:25:03 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2010-12-28 09:25:03 (GMT)
commit2272129a93d9492a42ef43987f829940d26dc862 (patch)
treee80a4341b5c8290f6ee9d46cd966b1a3805834b8
parent8578196b763a70746f2ab17170eb7ca9399ab8ac (diff)
downloadbusybox-2272129a93d9492a42ef43987f829940d26dc862.tar.gz
busybox-2272129a93d9492a42ef43987f829940d26dc862.tar.bz2
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 32c86ce..8436cd6 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)
char *retpath = NULL;
int len, rem;
- dir = opendir(ap->devpath);
- if (!dir)
- return NULL;
-
len = strlen(ap->devpath);
rem = DEVNAME_MAX-2 - len;
if (rem <= 0)
return NULL;
+
+ dir = opendir(ap->devpath);
+ if (!dir)
+ return NULL;
+
ap->devpath[len++] = '/';
while ((entry = readdir(dir)) != NULL) {