From: Wim Coekaerts Date: Tue, 29 Dec 2015 06:23:47 +0000 (-0800) Subject: network.c:is_wlan() File Leak f X-Git-Tag: lxc-2.0.0.beta2~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee54ea9a28ba2314f86d07a9e080549f90454e02;p=thirdparty%2Flxc.git network.c:is_wlan() File Leak f 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 --- 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);