summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellLib/UefiShellLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg/Library/UefiShellLib/UefiShellLib.c')
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index e47d5350e0..53f54e1746 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -292,18 +292,12 @@ ShellLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
-
mEfiShellEnvironment2 = NULL;
gEfiShellProtocol = NULL;
gEfiShellParametersProtocol = NULL;
mEfiShellInterface = NULL;
mEfiShellEnvironment2Handle = NULL;
-
- if (mUnicodeCollationProtocol == NULL) {
- Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol);
- ASSERT_EFI_ERROR (Status);
- }
+ mUnicodeCollationProtocol = NULL;
//
// verify that auto initialize is not set false
@@ -730,6 +724,14 @@ ShellOpenFileByName(
FileHandle,
OpenMode);
+ if (mUnicodeCollationProtocol == NULL) {
+ Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol);
+ if (EFI_ERROR (Status)) {
+ gEfiShellProtocol->CloseFile (*FileHandle);
+ return Status;
+ }
+ }
+
if ((mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NUL") != 0) &&
(mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NULL") != 0) &&
!EFI_ERROR(Status) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){