MdeModulePkg: Fix conditionally uninitialized variables

Fixes CodeQL alerts for CWE-457:
https://cwe.mitre.org/data/definitions/457.html

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Erich McMillan <emcmillan@microsoft.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Co-authored-by: Erich McMillan <emcmillan@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
This commit is contained in:
Michael Kubacki
2022-11-08 15:24:54 -05:00
committed by mergify[bot]
parent 84d77d9bf5
commit 07251f3c6a
9 changed files with 80 additions and 56 deletions

View File

@@ -1745,6 +1745,7 @@ HiiStringToImage (
Attributes = (UINT8 *)AllocateZeroPool (StrLength * sizeof (UINT8));
ASSERT (Attributes != NULL);
FontInfo = NULL;
RowInfo = NULL;
Status = EFI_SUCCESS;
StringIn2 = NULL;
@@ -1787,11 +1788,14 @@ HiiStringToImage (
Background = ((EFI_FONT_DISPLAY_INFO *)StringInfo)->BackgroundColor;
} else if (Status == EFI_SUCCESS) {
FontInfo = &StringInfoOut->FontInfo;
IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont);
Height = GlobalFont->FontPackage->Height;
BaseLine = GlobalFont->FontPackage->BaseLine;
Foreground = StringInfoOut->ForegroundColor;
Background = StringInfoOut->BackgroundColor;
if (IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont)) {
Height = GlobalFont->FontPackage->Height;
BaseLine = GlobalFont->FontPackage->BaseLine;
Foreground = StringInfoOut->ForegroundColor;
Background = StringInfoOut->BackgroundColor;
} else {
goto Exit;
}
} else {
goto Exit;
}