From 2ef2b9df0d01363e73a8537d85d8b27631ab8090 Mon Sep 17 00:00:00 2001 From: jief666 Date: Wed, 19 Aug 2020 10:52:07 +0300 Subject: [PATCH] Allow empty dict --- rEFIt_UEFI/Platform/Settings.cpp | 12 ++++++------ rEFIt_UEFI/Platform/plist.h | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 23a421eb1..d4236c419 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -510,7 +510,7 @@ LoadUserSettings ( { EFI_STATUS Status = EFI_NOT_FOUND; UINTN Size = 0; - CHAR8* gConfigPtr = NULL; + CHAR8* ConfigPtr = NULL; XStringW ConfigPlistPath; XStringW ConfigOemPath; @@ -524,16 +524,16 @@ LoadUserSettings ( ConfigPlistPath = SWPrintf("EFI\\CLOVER\\%ls.plist", ConfName.wc_str()); ConfigOemPath = SWPrintf("%ls\\%ls.plist", OEMPath.wc_str(), ConfName.wc_str()); if (FileExists (SelfRootDir, ConfigOemPath)) { - Status = egLoadFile(SelfRootDir, ConfigOemPath.wc_str(), (UINT8**)&gConfigPtr, &Size); + Status = egLoadFile(SelfRootDir, ConfigOemPath.wc_str(), (UINT8**)&ConfigPtr, &Size); } if (EFI_ERROR(Status)) { if ((RootDir != NULL) && FileExists (RootDir, ConfigPlistPath)) { - Status = egLoadFile(RootDir, ConfigPlistPath.wc_str(), (UINT8**)&gConfigPtr, &Size); + Status = egLoadFile(RootDir, ConfigPlistPath.wc_str(), (UINT8**)&ConfigPtr, &Size); } if (!EFI_ERROR(Status)) { DBG("Using %ls.plist at RootDir at path: %ls\n", ConfName.wc_str(), ConfigPlistPath.wc_str()); } else { - Status = egLoadFile(SelfRootDir, ConfigPlistPath.wc_str(), (UINT8**)&gConfigPtr, &Size); + Status = egLoadFile(SelfRootDir, ConfigPlistPath.wc_str(), (UINT8**)&ConfigPtr, &Size); if (!EFI_ERROR(Status)) { DBG("Using %ls.plist at SelfRootDir at path: %ls\n", ConfName.wc_str(), ConfigPlistPath.wc_str()); }else{ @@ -544,8 +544,8 @@ LoadUserSettings ( DBG("Using %ls.plist at SelfRootDir at path: %ls\n", ConfName.wc_str(), ConfigOemPath.wc_str()); } - if (!EFI_ERROR(Status) && gConfigPtr != NULL) { - Status = ParseXML((const CHAR8*)gConfigPtr, Dict, (UINT32)Size); + if (!EFI_ERROR(Status) && ConfigPtr != NULL) { + Status = ParseXML((const CHAR8*)ConfigPtr, Dict, (UINT32)Size); if (EFI_ERROR(Status)) { // Dict = NULL; DBG("config.plist parse error Status=%s\n", strerror(Status)); diff --git a/rEFIt_UEFI/Platform/plist.h b/rEFIt_UEFI/Platform/plist.h index 8c5967d1b..b055dc48e 100644 --- a/rEFIt_UEFI/Platform/plist.h +++ b/rEFIt_UEFI/Platform/plist.h @@ -116,7 +116,7 @@ public: } void setDataValue(UINT8* data, UINTN dataLen) { - if ( data == NULL ) panic("TagStruct::setDictValue() : _data == NULL "); + if ( data == NULL ) panic("TagStruct::setDataValue() : _data == NULL "); _data = data; _dataLen = dataLen; type = kTagTypeData; @@ -141,9 +141,10 @@ public: } void setDictTagValue(TagStruct* tagList) { - if ( tagList == NULL ) panic("TagStruct::setDictValue() : tagList == NULL "); - if ( _tag != NULL ) panic("TagStruct::setDictValue() : _tag != NULL "); - if ( _nextTag != NULL ) panic("TagStruct::setDictValue() : _nextTag != NULL "); + // empty dict is allowed + //if ( tagList == NULL ) panic("TagStruct::setDictTagValue() : tagList == NULL "); + if ( _tag != NULL ) panic("TagStruct::setDictTagValue() : _tag != NULL "); + if ( _nextTag != NULL ) panic("TagStruct::setDictTagValue() : _nextTag != NULL "); _tag = tagList; _nextTag = NULL; type = kTagTypeDict;