Skip to content

Commit ef5056a

Browse files
authored
Merge pull request #1835 from dvovk/fix_unsafeptr
fix nil ptr
2 parents 3608872 + 244d63d commit ef5056a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cpu/cpu_darwin.go

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package cpu
55

66
import (
77
"context"
8+
"errors"
89
"fmt"
910
"strconv"
1011
"strings"
@@ -152,6 +153,10 @@ func perCPUTimes(machLib *common.Library) ([]TimesStat, error) {
152153
return nil, fmt.Errorf("host_processor_info error=%d", status)
153154
}
154155

156+
if cpuload == nil {
157+
return nil, errors.New("host_processor_info returned nil cpuload")
158+
}
159+
155160
defer vmDeallocate(machTaskSelf(), uintptr(unsafe.Pointer(cpuload)), uintptr(ncpu))
156161

157162
ret := []TimesStat{}

0 commit comments

Comments
 (0)