From d373079f3544b3e36fab38e3ccc3df6ca3fb004f Mon Sep 17 00:00:00 2001 From: Luke Champine Date: Wed, 13 Jan 2021 12:11:26 -0500 Subject: [PATCH] Prevent panic in darwin AVX512 detection --- cpu_darwin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu_darwin.go b/cpu_darwin.go index e2c48d6..5af5635 100644 --- a/cpu_darwin.go +++ b/cpu_darwin.go @@ -17,6 +17,6 @@ func init() { if !haveAVX512 { // On some Macs, AVX512 detection is buggy, so fallback to sysctl b, _ := syscall.Sysctl("hw.optional.avx512f") - haveAVX512 = b[0] == 1 + haveAVX512 = len(b) > 0 && b[0] == 1 } }