From 983fffd4310ad3c532794ac923b3d55a1da14093 Mon Sep 17 00:00:00 2001 From: Jaben Carsey Date: Tue, 28 Jul 2015 20:22:26 +0000 Subject: [PATCH] ShellPkg: prevent Close call when Open failed Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey Reviewed-by: Tapan Shah Reviewed-by: Erik Bjorge git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18096 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 0c99e23650..6e0f61130f 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -702,8 +702,9 @@ ShellOpenFileByName( } PathCleanUpDirectories (FileNameCopy); if (PathRemoveLastItem (FileNameCopy)) { - ShellCreateDirectory (FileNameCopy, FileHandle); - ShellCloseFile (FileHandle); + if (!EFI_ERROR(ShellCreateDirectory (FileNameCopy, FileHandle))) { + ShellCloseFile (FileHandle); + } } SHELL_FREE_NON_NULL (FileNameCopy); }