Skip to content

Instantly share code, notes, and snippets.

@STRRL
Created November 27, 2021 04:35
Show Gist options
  • Save STRRL/09fd544c1281a8d0273a85e767f5b3ac to your computer and use it in GitHub Desktop.
Save STRRL/09fd544c1281a8d0273a85e767f5b3ac to your computer and use it in GitHub Desktop.
diff --git a/collector/thermal_darwin.go b/collector/thermal_darwin.go
index 282ca3f..fa96f1f 100644
--- a/collector/thermal_darwin.go
+++ b/collector/thermal_darwin.go
@@ -118,7 +118,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 C.kIOReturnSuccess == cfDictRef.ret {
+ C.CFRelease(C.CFTypeRef(cfDictRef.ref))
+ }
}()
if C.kIOReturnNotFound == cfDictRef.ret {
@STRRL
Copy link
Author

STRRL commented Nov 27, 2021

PTAL @kmahyyg , THANKS A LOT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment