1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-02 22:17:08 +08:00

Merge pull request #789 from shirou/feature/add_length_check_to_cpuinfo

[cpu][linux]: add cpuinfo parse check.
This commit is contained in:
Lomanic 2019-11-17 00:56:34 +01:00 committed by GitHub
commit c9a2a69ca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,7 +87,7 @@ func finishCPUInfo(c *InfoStat) error {
lines, err = common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq")) lines, err = common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq"))
// if we encounter errors below such as there are no cpuinfo_max_freq file, // if we encounter errors below such as there are no cpuinfo_max_freq file,
// we just ignore. so let Mhz is 0. // we just ignore. so let Mhz is 0.
if err != nil { if err != nil || len(lines) == 0 {
return nil return nil
} }
value, err = strconv.ParseFloat(lines[0], 64) value, err = strconv.ParseFloat(lines[0], 64)