MdeModulePkg/HiiDataBase: Fix NULL deference bug in HiiGetImageInfo

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 <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Ruiyu Ni 2016-09-30 12:29:24 +08:00
parent 202726b3ce
commit 4558491f87
1 changed files with 4 additions and 0 deletions

View File

@ -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: