summaryrefslogtreecommitdiff
path: root/ShellPkg/Application/Shell/FileHandleWrappers.c
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg/Application/Shell/FileHandleWrappers.c')
-rw-r--r--ShellPkg/Application/Shell/FileHandleWrappers.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c
index 2e1ce08ef3..2ca13cb3f3 100644
--- a/ShellPkg/Application/Shell/FileHandleWrappers.c
+++ b/ShellPkg/Application/Shell/FileHandleWrappers.c
@@ -1327,7 +1327,8 @@ FileInterfaceMemGetPosition(
@param[in, out] BufferSize Size in bytes of Buffer.
@param[in] Buffer The pointer to the buffer to write.
- @retval EFI_SUCCESS The data was written.
+ @retval EFI_OUT_OF_RESOURCES The operation failed due to lack of resources.
+ @retval EFI_SUCCESS The data was written.
**/
EFI_STATUS
EFIAPI
@@ -1354,6 +1355,9 @@ FileInterfaceMemWrite(
// Ascii
//
AsciiBuffer = AllocateZeroPool(*BufferSize);
+ if (AsciiBuffer == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
if ((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize)) {
((EFI_FILE_PROTOCOL_MEM*)This)->Buffer = ReallocatePool((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize), (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize) + AsciiStrSize(AsciiBuffer) + 10, ((EFI_FILE_PROTOCOL_MEM*)This)->Buffer);