Skip to content

Commit a19cede

Browse files
authored
Merge pull request #1727 from uubulb/fix_sensors_darwin_arm64
sensors: avoid passing nil pointer to CFArrayGetCount
2 parents c9da2cc + 10d9c04 commit a19cede

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sensors/sensors_darwin_arm64.go

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ func (ta *temperatureArm) getProductNames() []string {
9696
ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors))
9797
matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system))
9898

99+
if matchingsrvs == nil {
100+
return nil
101+
}
102+
99103
count := ta.cfArrayGetCount(uintptr(matchingsrvs))
100104

101105
var i int32
@@ -130,6 +134,10 @@ func (ta *temperatureArm) getThermalValues() []float64 {
130134
ta.ioHIDEventSystemClientSetMatching(uintptr(system), uintptr(ta.sensors))
131135
matchingsrvs := ta.ioHIDEventSystemClientCopyServices(uintptr(system))
132136

137+
if matchingsrvs == nil {
138+
return nil
139+
}
140+
133141
count := ta.cfArrayGetCount(uintptr(matchingsrvs))
134142

135143
var values []float64

0 commit comments

Comments
 (0)