summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 54b6a43e0..66fcc9f89 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -2005,6 +2005,7 @@ CopyReplace(
IN CONST CHAR16 *FindTarget,
IN CONST CHAR16 *ReplaceWith
){
+ UINTN Size;
if ( (SourceString == NULL)
|| (NewString == NULL)
|| (FindTarget == NULL)
@@ -2018,12 +2019,14 @@ CopyReplace(
while (*SourceString != L'\0') {
if (StrnCmp(SourceString, FindTarget, StrLen(FindTarget)) == 0) {
SourceString += StrLen(FindTarget);
- if ((StrSize(NewString) + (StrLen(ReplaceWith)*sizeof(CHAR16))) > NewSize) {
+ Size = StrSize(NewString);
+ if ((Size + (StrLen(ReplaceWith)*sizeof(CHAR16))) > NewSize) {
return (EFI_BUFFER_TOO_SMALL);
}
StrCat(NewString, ReplaceWith);
} else {
- if (StrSize(NewString) + sizeof(CHAR16) > NewSize) {
+ Size = StrSize(NewString);
+ if (Size + sizeof(CHAR16) > NewSize) {
return (EFI_BUFFER_TOO_SMALL);
}
StrnCat(NewString, SourceString, 1);