diff --git a/CHANGELOG.md b/CHANGELOG.md index 675057ec..a152600b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * [ENHANCEMENT] * [BUGFIX] +* [BUGFIX] Handle nil CPU thermal power status on M1 #2218 + ## 1.3.0 / 2021-10-20 NOTE: In order to support globs in the textfile collector path, filenames exposed by diff --git a/collector/thermal_darwin.go b/collector/thermal_darwin.go index 282ca3f3..25673dcc 100644 --- a/collector/thermal_darwin.go +++ b/collector/thermal_darwin.go @@ -47,9 +47,10 @@ import "C" import ( "errors" "fmt" + "unsafe" + "github.com/go-kit/log" "github.com/prometheus/client_golang/prometheus" - "unsafe" ) type thermCollector struct { @@ -118,7 +119,9 @@ func (c *thermCollector) Update(ch chan<- prometheus.Metric) error { func fetchCPUPowerStatus() (map[string]int, error) { cfDictRef, _ := C.FetchThermal() defer func() { - C.CFRelease(C.CFTypeRef(cfDictRef.ref)) + if cfDictRef.ref != 0x0 { + C.CFRelease(C.CFTypeRef(cfDictRef.ref)) + } }() if C.kIOReturnNotFound == cfDictRef.ret {