ShellPkg: Fix memory leak in 'ShellOpenFileByName'.
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/trunk/edk2@19524 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -673,6 +673,7 @@ ShellOpenFileByName(
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_FILE_INFO *FileInfo;
|
EFI_FILE_INFO *FileInfo;
|
||||||
CHAR16 *FileNameCopy;
|
CHAR16 *FileNameCopy;
|
||||||
|
EFI_STATUS Status2;
|
||||||
|
|
||||||
//
|
//
|
||||||
// ASSERT if FileName is NULL
|
// ASSERT if FileName is NULL
|
||||||
@ -719,8 +720,12 @@ ShellOpenFileByName(
|
|||||||
FileInfo = FileFunctionMap.GetFileInfo(*FileHandle);
|
FileInfo = FileFunctionMap.GetFileInfo(*FileHandle);
|
||||||
ASSERT(FileInfo != NULL);
|
ASSERT(FileInfo != NULL);
|
||||||
FileInfo->Attribute = Attributes;
|
FileInfo->Attribute = Attributes;
|
||||||
Status = FileFunctionMap.SetFileInfo(*FileHandle, FileInfo);
|
Status2 = FileFunctionMap.SetFileInfo(*FileHandle, FileInfo);
|
||||||
FreePool(FileInfo);
|
FreePool(FileInfo);
|
||||||
|
if (EFI_ERROR (Status2)) {
|
||||||
|
gEfiShellProtocol->CloseFile(*FileHandle);
|
||||||
|
}
|
||||||
|
Status = Status2;
|
||||||
}
|
}
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user