summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-23 09:37:32 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-23 09:37:32 +0000
commit1e22d0b02cab304966c5008e37f60f903bec1de3 (patch)
treec7afd5b3c0c626a1ff7d6a86f8f2247724fdbdfe /EdkCompatibilityPkg
parent4b79797eeadc83a9ce1df5efe99d1f1248bbc887 (diff)
downloadedk2-platforms-1e22d0b02cab304966c5008e37f60f903bec1de3.tar.xz
Fix a bug in UefiDefaultsToFwDefaults NULL should be returned if no Variable pack is found.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5719 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c
index 07e157df4e..4c382d4eef 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c
@@ -652,6 +652,7 @@ UefiDefaultsToFwDefaults (
UINT16 DefaultId;
EFI_HII_VARIABLE_PACK *Pack;
EFI_HII_VARIABLE_PACK_LIST *PackList;
+ UINTN Index;
if (DefaultMask == FRAMEWORK_EFI_IFR_FLAG_DEFAULT) {
DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
@@ -685,6 +686,11 @@ UefiDefaultsToFwDefaults (
List = GetNextNode (ListHead, List);
}
+ if (Count == 0) {
+ *VariablePackList = NULL;
+ return EFI_NOT_FOUND;
+ }
+
Size = Size + Count * (sizeof (EFI_HII_VARIABLE_PACK_LIST) + sizeof (EFI_HII_VARIABLE_PACK));
*VariablePackList = AllocateZeroPool (Size);
@@ -694,6 +700,7 @@ UefiDefaultsToFwDefaults (
PackList = (EFI_HII_VARIABLE_PACK_LIST *) *VariablePackList;
Pack = (EFI_HII_VARIABLE_PACK *) (PackList + 1);
+ Index = 0;
while (!IsNull (ListHead, List)) {
Node = UEFI_IFR_BUFFER_STORAGE_NODE_FROM_LIST(List);
@@ -727,10 +734,13 @@ UefiDefaultsToFwDefaults (
Size += sizeof (EFI_HII_VARIABLE_PACK_LIST);
//
- // initialize EFI_HII_VARIABLE_PACK_LIST
+ // Initialize EFI_HII_VARIABLE_PACK_LIST
//
PackList->VariablePack = Pack;
- PackList->NextVariablePack = (EFI_HII_VARIABLE_PACK_LIST *)((UINT8 *) PackList + Size);
+ Index++;
+ if (Index < Count) {
+ PackList->NextVariablePack = (EFI_HII_VARIABLE_PACK_LIST *)((UINT8 *) PackList + Size);
+ }
}