From ee54ea9a28ba2314f86d07a9e080549f90454e02 Mon Sep 17 00:00:00 2001 From: Wim Coekaerts Date: Mon, 28 Dec 2015 22:23:47 -0800 Subject: [PATCH] network.c:is_wlan() File Leak f MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Signed-off-by: Wim Coekaerts Acked-by: Stéphane Graber Acked-by: Serge E. Hallyn --- src/lxc/network.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lxc/network.c b/src/lxc/network.c index a6740f56a..269e5e319 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -158,8 +158,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);