diff options
author | Yao Jiewen <Jiewen.Yao@intel.com> | 2015-12-25 02:13:44 +0000 |
---|---|---|
committer | hwu1225 <hwu1225@Edk2> | 2015-12-25 02:13:44 +0000 |
commit | d291c4b327ca65b1d5f22efe9b4cf86c9bc08962 (patch) | |
tree | 0305323bbdb07799c34b1051f98247216bb62951 | |
parent | 22ac7aba0f6fd4d1537fe18c43565abfeb360c61 (diff) | |
download | edk2-platforms-d291c4b327ca65b1d5f22efe9b4cf86c9bc08962.tar.xz |
ShellPkg: Fix memory leak in 'ShellOpenFileByName'.
(Sync patch r19524 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yao Jiewen <Jiewen.Yao@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19536 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 44ac382980..9e815c56a6 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -673,6 +673,7 @@ ShellOpenFileByName( EFI_STATUS Status;
EFI_FILE_INFO *FileInfo;
CHAR16 *FileNameCopy;
+ EFI_STATUS Status2;
//
// ASSERT if FileName is NULL
@@ -719,8 +720,12 @@ ShellOpenFileByName( FileInfo = FileFunctionMap.GetFileInfo(*FileHandle);
ASSERT(FileInfo != NULL);
FileInfo->Attribute = Attributes;
- Status = FileFunctionMap.SetFileInfo(*FileHandle, FileInfo);
+ Status2 = FileFunctionMap.SetFileInfo(*FileHandle, FileInfo);
FreePool(FileInfo);
+ if (EFI_ERROR (Status2)) {
+ gEfiShellProtocol->CloseFile(*FileHandle);
+ }
+ Status = Status2;
}
return (Status);
}
|