diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-12 18:13:41 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-18 10:55:35 +0800 |
commit | 3e9442a564a767f7bd60113117d7b993a4e29a9b (patch) | |
tree | cd9a75c865ec2a092e98aaece0cc8b408e186c22 /ShellPkg/Library | |
parent | 20cfed165c47a7ff578e469e4cf00f1a656eccbd (diff) | |
download | edk2-3e9442a564a767f7bd60113117d7b993a4e29a9b.tar.gz edk2-3e9442a564a767f7bd60113117d7b993a4e29a9b.tar.bz2 edk2-3e9442a564a767f7bd60113117d7b993a4e29a9b.zip |
ShellPkg/Edit: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c index acd8512ff3..efe0df0253 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c @@ -1,7 +1,7 @@ /** @file
Implements filebuffer interface functions.
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -505,29 +505,28 @@ FileBufferPrintLine ( BufLen = (MainEditor.ScreenSize.Column + 1) * sizeof (CHAR16);
PrintLine = AllocatePool (BufLen);
- ASSERT (PrintLine != NULL);
-
- StrnCpyS (PrintLine, BufLen/sizeof(CHAR16), Buffer, MIN(Limit, MainEditor.ScreenSize.Column));
- for (; Limit < MainEditor.ScreenSize.Column; Limit++) {
- PrintLine[Limit] = L' ';
- }
-
- PrintLine[MainEditor.ScreenSize.Column] = CHAR_NULL;
-
- PrintLine2 = AllocatePool (BufLen * 2);
- ASSERT (PrintLine2 != NULL);
+ if (PrintLine != NULL) {
+ StrnCpyS (PrintLine, BufLen/sizeof(CHAR16), Buffer, MIN(Limit, MainEditor.ScreenSize.Column));
+ for (; Limit < MainEditor.ScreenSize.Column; Limit++) {
+ PrintLine[Limit] = L' ';
+ }
- ShellCopySearchAndReplace(PrintLine, PrintLine2, BufLen * 2, L"%", L"^%", FALSE, FALSE);
+ PrintLine[MainEditor.ScreenSize.Column] = CHAR_NULL;
- ShellPrintEx (
- 0,
- (INT32)Row - 1,
- L"%s",
- PrintLine2
- );
+ PrintLine2 = AllocatePool (BufLen * 2);
+ if (PrintLine2 != NULL) {
+ ShellCopySearchAndReplace(PrintLine, PrintLine2, BufLen * 2, L"%", L"^%", FALSE, FALSE);
- FreePool (PrintLine);
- FreePool (PrintLine2);
+ ShellPrintEx (
+ 0,
+ (INT32)Row - 1,
+ L"%s",
+ PrintLine2
+ );
+ FreePool (PrintLine2);
+ }
+ FreePool (PrintLine);
+ }
return EFI_SUCCESS;
}
|