mirror of https://github.com/acidanthera/audk.git
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:
parent
4a723ed258
commit
b5bd3ed648
|
@ -704,6 +704,7 @@ FvSimpleFileSystemRead (
|
||||||
|
|
||||||
Status = FvFsReadFile (File->Instance->FvProtocol, File->FvFileInfo, &FileSize, &FileBuffer);
|
Status = FvFsReadFile (File->Instance->FvProtocol, File->FvFileInfo, &FileSize, &FileBuffer);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
FreePool (FileBuffer);
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,6 +715,8 @@ FvSimpleFileSystemRead (
|
||||||
CopyMem (Buffer, (UINT8*)FileBuffer + File->Position, *BufferSize);
|
CopyMem (Buffer, (UINT8*)FileBuffer + File->Position, *BufferSize);
|
||||||
File->Position += *BufferSize;
|
File->Position += *BufferSize;
|
||||||
|
|
||||||
|
FreePool (FileBuffer);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue