summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'IntelFrameworkModulePkg/Library')
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
index 3d1ccf9dc2..a432fb24a4 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
@@ -825,6 +825,7 @@ BdsLibGetVariableAndSize (
//
Buffer = AllocateZeroPool (BufferSize);
if (Buffer == NULL) {
+ *VariableSize = 0;
return NULL;
}
//
@@ -832,10 +833,15 @@ BdsLibGetVariableAndSize (
//
Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
if (EFI_ERROR (Status)) {
+ FreePool (Buffer);
BufferSize = 0;
+ Buffer = NULL;
}
}
+ ASSERT (((Buffer == NULL) && (BufferSize == 0)) ||
+ ((Buffer != NULL) && (BufferSize != 0))
+ );
*VariableSize = BufferSize;
return Buffer;
}