which weren't freeing line of closing an open file.
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
total_len += l;
}
+ fclose(f);
+ free(line);
return total_len;
}
}
}
+ fclose(f);
+ free(line);
return total_len;
}
total_len += l;
}
+ fclose(f);
+ free(line);
return total_len;
}
{
FILE *f = fopen("/proc/uptime", "r");
long int age, idle;
+ int ret;
if (!f)
return 0;
- if (fscanf(f, "%ld %ld", &age, &idle) != 2)
+ ret = fscanf(f, "%ld %ld", &age, &idle);
+ fclose(f);
+ if (ret != 2)
return 0;
return idle;
}
while ((sz = getline(&line, &len, f)) != -1)
answer += sz;
fclose (f);
+ free(line);
return answer;
}