The return value of GetImageIdOrAddress() could be NULL if the
ImageId is invalid. The patch fixes the bug to return EFI_NOT_FOUND
when GetImageIdOrAddress() returns NULL.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <[email protected]>
Cc: Liming Gao <[email protected]>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c 
b/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c
index 1e3f3bd..33dbc7d 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c
@@ -361,6 +361,10 @@ HiiGetImageInfo (
   // Find the image block specified by ImageId
   //
   CurrentImageBlock = GetImageIdOrAddress (ImagePackage->ImageBlock, &ImageId);
+  if (CurrentImageBlock == NULL) {
+    return EFI_NOT_FOUND;
+  }
+
   switch (CurrentImageBlock->BlockType) {
   case EFI_HII_IIBT_IMAGE_JPEG:
   case EFI_HII_IIBT_IMAGE_PNG:
-- 
2.9.0.windows.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to