Skip to content

Commit

Permalink
sensors: avoid passing nil pointer to CFArrayGetCount
Browse files Browse the repository at this point in the history
  • Loading branch information
uubulb committed Oct 7, 2024
1 parent 45e3591 commit 10d9c04
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sensors/sensors_darwin_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 10d9c04

Please sign in to comment.