Status = EFI_OUT_OF_RESOURCES;\r
break;\r
} else {\r
+ //\r
+ // Prepare to move to the parent directory.\r
+ // Also determine whether CurrentHandle refers to the Root directory.\r
+ //\r
+ Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle, L"..", EFI_FILE_MODE_READ, 0);\r
//\r
// We got info... do we have a name? if yes precede the current path with it...\r
//\r
- if (StrLen (FileInfo->FileName) == 0) {\r
+ if ((StrLen (FileInfo->FileName) == 0) || EFI_ERROR (Status)) {\r
+ //\r
+ // Both FileInfo->FileName being '\0' and EFI_ERROR() suggest that\r
+ // CurrentHandle refers to the Root directory. As this loop ensures\r
+ // FullFileName is starting with '\\' at all times, signal success\r
+ // and exit the loop.\r
+ // While FileInfo->FileName could theoretically be a value other than\r
+ // '\0' or '\\', '\\' is guaranteed to be supported by the\r
+ // specification and hence its value can safely be ignored.\r
+ //\r
+ Status = EFI_SUCCESS;\r
if (*FullFileName == NULL) {\r
ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
*FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
FreePool(FileInfo);\r
}\r
}\r
+\r
+ FileHandleClose(CurrentHandle);\r
//\r
// Move to the parent directory\r
//\r
- Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle, L"..", EFI_FILE_MODE_READ, 0);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- FileHandleClose(CurrentHandle);\r
CurrentHandle = NextHigherHandle;\r
}\r
} else if (Status == EFI_NOT_FOUND) {\r