mirror of https://github.com/acidanthera/audk.git
ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->Buffer
Add check for MemFile->Buffer. Return EFI_OUT_OF_RESOURCES if MemFile->Buffer is NULL. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
This commit is contained in:
parent
1bcc65b9a1
commit
dd6d07bda9
|
@ -1644,6 +1644,9 @@ FileInterfaceMemWrite(
|
|||
//
|
||||
if ((UINTN)(MemFile->Position + (*BufferSize)) > (UINTN)(MemFile->BufferSize)) {
|
||||
MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
|
||||
if (MemFile->Buffer == NULL){
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
MemFile->BufferSize += (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD;
|
||||
}
|
||||
CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, Buffer, *BufferSize);
|
||||
|
@ -1661,6 +1664,10 @@ FileInterfaceMemWrite(
|
|||
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
|
||||
if ((UINTN)(MemFile->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(MemFile->BufferSize)) {
|
||||
MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + AsciiStrSize(AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
|
||||
if (MemFile->Buffer == NULL){
|
||||
FreePool(AsciiBuffer);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
MemFile->BufferSize += AsciiStrSize(AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD;
|
||||
}
|
||||
CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, AsciiBuffer, AsciiStrSize(AsciiBuffer));
|
||||
|
|
Loading…
Reference in New Issue