summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c')
-rw-r--r--ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
index 0bee8e3899..fb9d4ec0be 100644
--- a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
+++ b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
@@ -509,9 +509,12 @@ FileHandleFindFirstFile (
//
Status = FileHandleRead (DirHandle, &BufferSize, *Buffer);
ASSERT(Status != EFI_BUFFER_TOO_SMALL);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR(Status) || BufferSize == 0) {
FreePool(*Buffer);
*Buffer = NULL;
+ if (BufferSize == 0) {
+ return (EFI_NOT_FOUND);
+ }
return (Status);
}
return (EFI_SUCCESS);