Merge pull request #1835 from dvovk/fix_unsafeptr

fix nil ptr
pull/1829/head
shirou 4 weeks ago committed by GitHub
commit ef5056a446
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,6 +5,7 @@ package cpu
import (
"context"
"errors"
"fmt"
"strconv"
"strings"
@ -152,6 +153,10 @@ func perCPUTimes(machLib *common.Library) ([]TimesStat, error) {
return nil, fmt.Errorf("host_processor_info error=%d", status)
}
if cpuload == nil {
return nil, errors.New("host_processor_info returned nil cpuload")
}
defer vmDeallocate(machTaskSelf(), uintptr(unsafe.Pointer(cpuload)), uintptr(ncpu))
ret := []TimesStat{}

Loading…
Cancel
Save