mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
20cfed165c
commit
3e9442a564
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Implements filebuffer interface functions.
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -505,30 +505,29 @@ FileBufferPrintLine (
|
||||||
|
|
||||||
BufLen = (MainEditor.ScreenSize.Column + 1) * sizeof (CHAR16);
|
BufLen = (MainEditor.ScreenSize.Column + 1) * sizeof (CHAR16);
|
||||||
PrintLine = AllocatePool (BufLen);
|
PrintLine = AllocatePool (BufLen);
|
||||||
ASSERT (PrintLine != NULL);
|
if (PrintLine != NULL) {
|
||||||
|
StrnCpyS (PrintLine, BufLen/sizeof(CHAR16), Buffer, MIN(Limit, MainEditor.ScreenSize.Column));
|
||||||
|
for (; Limit < MainEditor.ScreenSize.Column; Limit++) {
|
||||||
|
PrintLine[Limit] = L' ';
|
||||||
|
}
|
||||||
|
|
||||||
StrnCpyS (PrintLine, BufLen/sizeof(CHAR16), Buffer, MIN(Limit, MainEditor.ScreenSize.Column));
|
PrintLine[MainEditor.ScreenSize.Column] = CHAR_NULL;
|
||||||
for (; Limit < MainEditor.ScreenSize.Column; Limit++) {
|
|
||||||
PrintLine[Limit] = L' ';
|
PrintLine2 = AllocatePool (BufLen * 2);
|
||||||
|
if (PrintLine2 != NULL) {
|
||||||
|
ShellCopySearchAndReplace(PrintLine, PrintLine2, BufLen * 2, L"%", L"^%", FALSE, FALSE);
|
||||||
|
|
||||||
|
ShellPrintEx (
|
||||||
|
0,
|
||||||
|
(INT32)Row - 1,
|
||||||
|
L"%s",
|
||||||
|
PrintLine2
|
||||||
|
);
|
||||||
|
FreePool (PrintLine2);
|
||||||
|
}
|
||||||
|
FreePool (PrintLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintLine[MainEditor.ScreenSize.Column] = CHAR_NULL;
|
|
||||||
|
|
||||||
PrintLine2 = AllocatePool (BufLen * 2);
|
|
||||||
ASSERT (PrintLine2 != NULL);
|
|
||||||
|
|
||||||
ShellCopySearchAndReplace(PrintLine, PrintLine2, BufLen * 2, L"%", L"^%", FALSE, FALSE);
|
|
||||||
|
|
||||||
ShellPrintEx (
|
|
||||||
0,
|
|
||||||
(INT32)Row - 1,
|
|
||||||
L"%s",
|
|
||||||
PrintLine2
|
|
||||||
);
|
|
||||||
|
|
||||||
FreePool (PrintLine);
|
|
||||||
FreePool (PrintLine2);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue