Skip to content

MdeModulePkg: Correct CoreRemoveDebugImageInfoEntry() #11019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <Library/BaseMemoryLib.h>
#include "DxeMain.h"

EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugInfoTableHeader = {
Expand Down Expand Up @@ -264,16 +265,23 @@ CoreRemoveDebugImageInfoEntry (
for (Index = 0; Index < mMaxTableEntries; Index++) {
if ((Table[Index].NormalImage != NULL) && (Table[Index].NormalImage->ImageHandle == ImageHandle)) {
//
// Found a match. Free up the record, then NULL the pointer to indicate the slot
// is free.
// Found a match. Free up the table entry.
// Move the tail of the table one slot to the front.
//
CoreFreePool (Table[Index].NormalImage);
Table[Index].NormalImage = NULL;
CopyMem (
&Table[Index],
&Table[Index + 1],
(mDebugInfoTableHeader.TableSize - Index - 1) * sizeof (void *)
);
//
// Decrease the number of EFI_DEBUG_IMAGE_INFO elements and set the mDebugInfoTable in modified status.
// Decrease the number of EFI_DEBUG_IMAGE_INFO elements
// Set the freed pointer to NULL.
// Set the the modified status in mDebugInfoTable.
//
mDebugInfoTableHeader.TableSize--;
mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;
Table[mDebugInfoTableHeader.TableSize].NormalImage = NULL;
mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;
break;
}
}
Expand Down
Loading