diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-01-20 02:00:46 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-01-20 02:00:46 +0000 |
commit | fa7b3168fdfc8744f658a5ba5c4e433fc0ae7c82 (patch) | |
tree | b6247229dfecf191f45051e3b645e64d09406123 /MdeModulePkg/Library/UefiHiiLib | |
parent | d0720b57060cc8f8bd0c21cb9937bbb87b420d36 (diff) | |
download | edk2-fa7b3168fdfc8744f658a5ba5c4e433fc0ae7c82.zip edk2-fa7b3168fdfc8744f658a5ba5c4e433fc0ae7c82.tar.gz edk2-fa7b3168fdfc8744f658a5ba5c4e433fc0ae7c82.tar.bz2 |
K8:
1) Add in "check-for-null" before dereferencing a pointer.
2) unify the handling of EFI_OUT_OF_RESOURCE case.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7310 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Library/UefiHiiLib')
-rw-r--r-- | MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c index f5544d9..83e33d2 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -281,13 +281,13 @@ HiiLibGetHiiHandles ( OUT EFI_HII_HANDLE **HiiHandleBuffer
)
{
- UINTN BufferLength;
EFI_STATUS Status;
ASSERT (HandleBufferLength != NULL);
ASSERT (HiiHandleBuffer != NULL);
- BufferLength = 0;
+ *HandleBufferLength = 0;
+ *HiiHandleBuffer = NULL;
//
// Try to find the actual buffer size for HiiHandle Buffer.
@@ -296,27 +296,26 @@ HiiLibGetHiiHandles ( mHiiDatabaseProt,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
- &BufferLength,
+ HandleBufferLength,
*HiiHandleBuffer
);
-
+
if (Status == EFI_BUFFER_TOO_SMALL) {
- *HiiHandleBuffer = AllocateZeroPool (BufferLength);
+ *HiiHandleBuffer = AllocateZeroPool (*HandleBufferLength);
ASSERT (*HiiHandleBuffer != NULL);
Status = mHiiDatabaseProt->ListPackageLists (
mHiiDatabaseProt,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
- &BufferLength,
+ HandleBufferLength,
*HiiHandleBuffer
);
- //
- // we should not fail here.
- //
- ASSERT_EFI_ERROR (Status);
- }
- *HandleBufferLength = BufferLength;
+ if (EFI_ERROR (Status)) {
+ FreePool (*HiiHandleBuffer);
+ *HiiHandleBuffer = NULL;
+ }
+ }
return Status;
}
|