summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-09-07 01:55:33 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-09-07 01:55:33 +0000
commitf480fdc0f93d1c20f6e1460d0301fa1386359cde (patch)
tree558e5fcecf4f21a03b6420c85f8947df535b3dd5 /ShellPkg
parent81634bfb531b80090df896508e1b30d2f4afe11d (diff)
downloadedk2-platforms-f480fdc0f93d1c20f6e1460d0301fa1386359cde.tar.xz
Fix always allocate memory issue.
Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13706 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 1929349b20..222bd98acd 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -3142,11 +3142,13 @@ StrnCatGrow (
//
if (CurrentSize != NULL) {
NewSize = *CurrentSize;
- while (NewSize < (DestinationStartSize + (Count*sizeof(CHAR16)))) {
- NewSize += 2 * Count * sizeof(CHAR16);
+ if (NewSize < DestinationStartSize + (Count * sizeof(CHAR16))) {
+ while (NewSize < (DestinationStartSize + (Count*sizeof(CHAR16)))) {
+ NewSize += 2 * Count * sizeof(CHAR16);
+ }
+ *Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);
+ *CurrentSize = NewSize;
}
- *Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);
- *CurrentSize = NewSize;
} else {
*Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));
}