From 0205c62cc4e9156548021437ecfedb7f8ef33c05 Mon Sep 17 00:00:00 2001 From: Amir Szekely Date: Tue, 18 Jan 2022 15:48:50 -0800 Subject: [PATCH] fix: x64 memory collection panic Don't read strings that are not there from virtual SMBIOS --- providers/memory.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/providers/memory.go b/providers/memory.go index 3b49e8e..42e7c2d 100644 --- a/providers/memory.go +++ b/providers/memory.go @@ -193,7 +193,9 @@ func readMemoryDevice(record *smbios.Structure) MemoryDevice { binary.Read(recordBytes, binary.LittleEndian, &memDevice.MaximumVoltage) binary.Read(recordBytes, binary.LittleEndian, &memDevice.ConfiguredVoltage) - memDevice.Location = record.Strings[0] + if len(record.Strings) >= 1 { + memDevice.Location = record.Strings[0] + } return memDevice }