Skip to content

Commit

Permalink
MdeModulePkg: DeviceManagerUiLib: Fix using uninitialized variable
Browse files Browse the repository at this point in the history
There could a path where the variable is used without being initialized.

This change initialized the variable at the function entry.

Cc: Liming Gao <[email protected]>
Cc: Zhichao Gao <[email protected]>
Cc: Ray Ni <[email protected]>
Signed-off-by: Kun Qin <[email protected]>
(cherry picked from commit 4298c31)
  • Loading branch information
kuqin12 committed Jul 30, 2024
1 parent 21de3ac commit ef4ea92
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ CreateDeviceManagerForm (
TempSize = 0;
BufferSize = 0;
Buffer = NULL;
HiiHandles = NULL; // MU_CHANGE - Initialize HiiHandles to NULL

HiiHandle = gDeviceManagerPrivate.HiiHandle;
AddNetworkMenu = FALSE;
Expand Down Expand Up @@ -745,7 +746,10 @@ CreateDeviceManagerForm (

HiiFreeOpCodeHandle (StartOpCodeHandle);
HiiFreeOpCodeHandle (EndOpCodeHandle);
FreePool (HiiHandles);
// MU_CHANGE: Only free HiiHandles if it is not NULL
if (HiiHandles != NULL) {
FreePool (HiiHandles);
}
}

/**
Expand Down

0 comments on commit ef4ea92

Please sign in to comment.