From 6ca34fe0c2d4c12a7434ae5e686bdd1e0a24c19b Mon Sep 17 00:00:00 2001 From: Goldfish64 Date: Sat, 10 Oct 2020 09:27:41 -0500 Subject: [PATCH] OcSmbiosLib: Provide fallbacks for NULL memory SMBIOS strings --- Changelog.md | 1 + Library/OcSmbiosLib/SmbiosPatch.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index 29643d25..806ae83e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ OpenCore Changelog #### v0.6.3 - Added support for xml comments in plist files - Updated underlying EDK II package to edk2-stable202008 +- Provide fallbacks for NULL memory SMBIOS strings #### v0.6.2 - Updated builtin firmware versions for SMBIOS and the rest diff --git a/Library/OcSmbiosLib/SmbiosPatch.c b/Library/OcSmbiosLib/SmbiosPatch.c index ad88ac68..6a7ce1e0 100755 --- a/Library/OcSmbiosLib/SmbiosPatch.c +++ b/Library/OcSmbiosLib/SmbiosPatch.c @@ -696,10 +696,14 @@ PatchMemoryDevice ( Table->CurrentPtr.Standard.Type17->MemoryErrorInformationHandle = 0xFFFF; } - SMBIOS_OVERRIDE_S (Table, Standard.Type17->Manufacturer, Original, NULL, &StringIndex, NULL); - SMBIOS_OVERRIDE_S (Table, Standard.Type17->SerialNumber, Original, NULL, &StringIndex, NULL); - SMBIOS_OVERRIDE_S (Table, Standard.Type17->AssetTag, Original, NULL, &StringIndex, NULL); - SMBIOS_OVERRIDE_S (Table, Standard.Type17->PartNumber, Original, NULL, &StringIndex, NULL); + // + // Some machines may have NULL values for these fields, which will cause SPMemoryReporter + // crashes or ??? to be displayed in About This Mac. Fallback to "Unknown" for such fields. + // + SMBIOS_OVERRIDE_S (Table, Standard.Type17->Manufacturer, Original, NULL, &StringIndex, "Unknown"); + SMBIOS_OVERRIDE_S (Table, Standard.Type17->SerialNumber, Original, NULL, &StringIndex, "Unknown"); + SMBIOS_OVERRIDE_S (Table, Standard.Type17->AssetTag, Original, NULL, &StringIndex, "Unknown"); + SMBIOS_OVERRIDE_S (Table, Standard.Type17->PartNumber, Original, NULL, &StringIndex, "Unknown"); SMBIOS_OVERRIDE_V (Table, Standard.Type17->Attributes, Original, NULL, NULL); SMBIOS_OVERRIDE_V (Table, Standard.Type17->ExtendedSize, Original, NULL, NULL);