From 10d9c04c2e6ba871b3f32f1dab3889fa0016960c Mon Sep 17 00:00:00 2001 From: uubulb Date: Tue, 8 Oct 2024 00:31:59 +0800 Subject: [PATCH] sensors: avoid passing nil pointer to CFArrayGetCount --- sensors/sensors_darwin_arm64.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sensors/sensors_darwin_arm64.go b/sensors/sensors_darwin_arm64.go index 2cf5b4869..509faddcf 100644 --- a/sensors/sensors_darwin_arm64.go +++ b/sensors/sensors_darwin_arm64.go @@ -96,6 +96,10 @@ func (ta *temperatureArm) getProductNames() []string { ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors)) matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system)) + if matchingsrvs == nil { + return nil + } + count := ta.cfArrayGetCount(uintptr(matchingsrvs)) var i int32 @@ -130,6 +134,10 @@ func (ta *temperatureArm) getThermalValues() []float64 { ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors)) matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system)) + if matchingsrvs == nil { + return nil + } + count := ta.cfArrayGetCount(uintptr(matchingsrvs)) var values []float64