From c587fd3eddce6532b3b71bf80a9cf0d70b7f45e7 Mon Sep 17 00:00:00 2001 From: Qiu Shumin Date: Thu, 2 Jul 2015 01:12:03 +0000 Subject: [PATCH] ShellPkg: Refine the code logic of StrnCatGrow. In order to indicate the catena length use StrnCatS instead of StrCatS to generate Destination string, and update the DestMax of Destination string. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin Reviewed-by: Tapan Shah Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17795 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 5b4c6d3fb7..3521515468 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -3254,7 +3254,8 @@ StrnCatGrow ( *CurrentSize = NewSize; } } else { - *Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16)); + NewSize = (Count+1)*sizeof(CHAR16); + *Destination = AllocateZeroPool(NewSize); } // @@ -3264,7 +3265,7 @@ StrnCatGrow ( return (NULL); } - StrCatS(*Destination, Count + 1, Source); + StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, Count); return *Destination; } -- 2.39.2