diff --git a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c index fb9d4ec0be..2085f6c521 100644 --- a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c +++ b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c @@ -84,9 +84,9 @@ FileHandleGetInfo ( // // if we got an error free the memory and return NULL // - if (EFI_ERROR(Status)) { + if (EFI_ERROR(Status) && (FileInfo != NULL)) { FreePool(FileInfo); - return NULL; + FileInfo = NULL; } } return (FileInfo);