From 1205492d1c6bf7d8e938b47a76f7d0e4a8a8844f Mon Sep 17 00:00:00 2001 From: Joursoir Date: Thu, 9 Dec 2021 21:13:09 +0300 Subject: dir: make release of EFI_SHELL_FILE_INFO memory more safer --- Library/UefiShellUfmCommandLib/dir.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/UefiShellUfmCommandLib/dir.c b/Library/UefiShellUfmCommandLib/dir.c index 782334d..2d50173 100644 --- a/Library/UefiShellUfmCommandLib/dir.c +++ b/Library/UefiShellUfmCommandLib/dir.c @@ -32,10 +32,12 @@ struct dir_list *dirl_alloc(CHAR16 *search_path, CONST UINT64 attr) // I have stolen code below in the source code of InternalFreeShellFileInfoNode(): RemoveEntryList(&node->Link); - FreePool((VOID*)node->Info); + if(node->Info != NULL) + FreePool((VOID*)node->Info); FreePool((VOID*)node->FileName); FreePool((VOID*)node->FullName); - gEfiShellProtocol->CloseFile(node->Handle); + if(node->Handle != NULL) + gEfiShellProtocol->CloseFile(node->Handle); FreePool(node); node = tmp; continue; -- cgit v1.2.3-18-g5258