Revision: 19536
http://sourceforge.net/p/edk2/code/19536
Author: hwu1225
Date: 2015-12-25 02:13:44 +0000 (Fri, 25 Dec 2015)
Log Message:
-----------
ShellPkg: Fix memory leak in 'ShellOpenFileByName'.
(Sync patch r19524 from main trunk.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yao Jiewen <[email protected]>
Reviewed-by: Qiu Shumin <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/19524
Modified Paths:
--------------
branches/UDK2015/ShellPkg/Library/UefiShellLib/UefiShellLib.c
Modified: branches/UDK2015/ShellPkg/Library/UefiShellLib/UefiShellLib.c
===================================================================
--- branches/UDK2015/ShellPkg/Library/UefiShellLib/UefiShellLib.c
2015-12-25 02:13:23 UTC (rev 19535)
+++ branches/UDK2015/ShellPkg/Library/UefiShellLib/UefiShellLib.c
2015-12-25 02:13:44 UTC (rev 19536)
@@ -673,6 +673,7 @@
EFI_STATUS Status;
EFI_FILE_INFO *FileInfo;
CHAR16 *FileNameCopy;
+ EFI_STATUS Status2;
//
// ASSERT if FileName is NULL
@@ -719,8 +720,12 @@
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);
}
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits