From: Qiu Shumin Date: Sun, 13 Dec 2015 08:44:49 +0000 (+0000) Subject: ShellPkg: Initialize the local pointer to avoid potential suspicious dereference. X-Git-Tag: edk2-stable201903~8312 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=02d3482574ed2b0b5435563c234563bea2167634;hp=898378c2be038bfbee21a8dd284a3dc3c5bb8f5e ShellPkg: Initialize the local pointer to avoid potential suspicious dereference. 1. Initialize the local pointer 'HandleBuffer'. 2. When 'LocateHandleBuffer' return error 'HandleBuffer' is expected unchanged, add code make sure this. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin Reviewed-by: Ruiyu Ni git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19229 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c index 3f08cc84dc..7b26e4d27f 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c @@ -317,6 +317,7 @@ ShellMmLocateIoProtocol ( } *PciRootBridgeIo = NULL; + HandleBuffer = NULL; Status = gBS->LocateHandleBuffer ( ByProtocol, &gEfiPciRootBridgeIoProtocolGuid, @@ -324,7 +325,7 @@ ShellMmLocateIoProtocol ( &HandleCount, &HandleBuffer ); - if (EFI_ERROR (Status) || (HandleCount == 0)) { + if (EFI_ERROR (Status) || (HandleCount == 0) || (HandleBuffer == NULL)) { return FALSE; }