MdeModulePkg FvSimpleFileSystemDxe: Fix memory leak in Read function

FvSimpleFileSystem on read always allocates a FileBuffer, and never frees
it. This causes memory leaks. It is especially bad for reading scripts
line-by-line. In some cases memory leak can exceed 1GB.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vladimir Olovyannikiov <vladimir.olovyannikov@broadcom.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Vladimir Olovyannikov 2018-07-26 03:47:49 +08:00 committed by Star Zeng
parent 4a723ed258
commit b5bd3ed648
1 changed files with 3 additions and 0 deletions

View File

@ -704,6 +704,7 @@ FvSimpleFileSystemRead (
Status = FvFsReadFile (File->Instance->FvProtocol, File->FvFileInfo, &FileSize, &FileBuffer);
if (EFI_ERROR (Status)) {
FreePool (FileBuffer);
return EFI_DEVICE_ERROR;
}
@ -714,6 +715,8 @@ FvSimpleFileSystemRead (
CopyMem (Buffer, (UINT8*)FileBuffer + File->Position, *BufferSize);
File->Position += *BufferSize;
FreePool (FileBuffer);
return EFI_SUCCESS;
}
}