From: Denys Vlasenko Date: Tue, 28 Dec 2010 09:25:03 +0000 (+0100) Subject: plug a DIR* leak on error path X-Git-Tag: 1_19_0~431 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2272129a93d9492a42ef43987f829940d26dc862;p=oweals%2Fbusybox.git plug a DIR* leak on error path Signed-off-by: Denys Vlasenko --- 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) 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) {