Browse Source

sysinfos: fix some file leaks

pull/2/head
Tanguy Pruvot 8 years ago
parent
commit
9dedec5ecd
  1. 6
      api.cpp
  2. 3
      sysinfos.cpp

6
api.cpp

@ -321,8 +321,12 @@ static const char* os_name() @@ -321,8 +321,12 @@ static const char* os_name()
return "windows";
#else
FILE *fd = fopen("/proc/version", "r");
if (!fd || !fscanf(fd, "Linux version %48s", &os_version[6]))
if (!fd)
return "linux";
if (!fscanf(fd, "Linux version %48s", &os_version[6])) {
fclose(fd);
return "linux";
}
fclose(fd);
os_version[48] = '\0';
return (const char*) os_version;

3
sysinfos.cpp

@ -50,8 +50,9 @@ static uint32_t linux_cpufreq(int core) @@ -50,8 +50,9 @@ static uint32_t linux_cpufreq(int core)
return freq;
if (!fscanf(fd, "%d", &freq))
return freq;
;
fclose(fd);
return freq;
}

Loading…
Cancel
Save