wifi_perc: Fix file descriptor leak

This commit is contained in:
Aaron Marcher 2018-05-02 19:41:53 +02:00
parent af3cdfbbc8
commit 699f6734d9
1 changed files with 3 additions and 2 deletions

View File

@ -30,10 +30,11 @@
strerror(errno)); strerror(errno));
return NULL; return NULL;
} }
if(!(p = fgets(status, 5, fp)) || strcmp(status, "up\n") != 0) { p = fgets(status, 5, fp);
fclose(fp);
if(!p || strcmp(status, "up\n") != 0) {
return NULL; return NULL;
} }
fclose(fp);
if (!(fp = fopen("/proc/net/wireless", "r"))) { if (!(fp = fopen("/proc/net/wireless", "r"))) {
fprintf(stderr, "fopen '/proc/net/wireless': %s\n", fprintf(stderr, "fopen '/proc/net/wireless': %s\n",