daemon: fix file descriptor leaks

This commit is contained in:
Matthias Gerstner
2019-04-03 16:27:12 +02:00
parent 618997f0b3
commit d7394cbeb2
4 changed files with 23 additions and 10 deletions

View File

@@ -50,7 +50,10 @@ enum GPUVendor gamemode_get_gpu_vendor(long device)
return Vendor_Invalid;
}
char buff[64];
if (fgets(buff, 64, file) != NULL) {
bool got_line = fgets(buff, 64, file) != NULL;
fclose(file);
if (got_line) {
vendor = strtol(buff, NULL, 0);
} else {
LOG_ERROR("Coudn't read contents of file %s, will not apply optimisations!\n", path);