[lxc-devel] [PATCH] network.c:is_wlan() File Leak f f initialized at line 156 with fopen f leaks when fopen(path, r) != NULL at line 156 and physname == NULL at line 163.

wim.coekaerts at oracle.com wim.coekaerts at oracle.com
Tue Dec 29 06:23:47 UTC 2015


From: Wim Coekaerts <wim.coekaerts at oracle.com>

Signed-off-by: Wim Coekaerts <wim.coekaerts at oracle.com>
---
 src/lxc/network.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index d4b015d..3417928 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -160,8 +160,10 @@ static char * is_wlan(const char *ifname)
 	physlen = ftell(f);
 	fseek(f, 0, SEEK_SET);
 	physname = malloc(physlen+1);
-	if (!physname)
+	if (!physname) {
+		fclose(f);	
 		goto bad;
+	}
 	memset(physname, 0, physlen+1);
 	ret = fread(physname, 1, physlen, f);
 	fclose(f);
-- 
1.7.1



More information about the lxc-devel mailing list