diff --git a/MdeModulePkg/Core/Dxe/Hand/Locate.c b/MdeModulePkg/Core/Dxe/Hand/Locate.c index a29010a545..8f20c6332d 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Locate.c +++ b/MdeModulePkg/Core/Dxe/Hand/Locate.c @@ -1,7 +1,7 @@ /** @file Locate handle functions -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -730,6 +730,10 @@ CoreLocateHandleBuffer ( *NumberHandles = BufferSize / sizeof (EFI_HANDLE); if (EFI_ERROR (Status)) { *NumberHandles = 0; + if (*Buffer != NULL) { + CoreFreePool (*Buffer); + *Buffer = NULL; + } } CoreReleaseProtocolLock ();