]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Refine the code logic of StrnCatGrow.
authorQiu Shumin <shumin.qiu@intel.com>
Thu, 2 Jul 2015 01:12:03 +0000 (01:12 +0000)
committershenshushi <shenshushi@Edk2>
Thu, 2 Jul 2015 01:12:03 +0000 (01:12 +0000)
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 <shumin.qiu@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hp.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17795 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 5b4c6d3fb7e392468aa1a79b79c193779d865d48..352151546883ebf00dbab415ac6a0fa463bc9ede 100644 (file)
@@ -3254,7 +3254,8 @@ StrnCatGrow (
       *CurrentSize = NewSize;\r
     }\r
   } else {\r
-    *Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));\r
+    NewSize = (Count+1)*sizeof(CHAR16);\r
+    *Destination = AllocateZeroPool(NewSize);\r
   }\r
 \r
   //\r
@@ -3264,7 +3265,7 @@ StrnCatGrow (
     return (NULL);\r
   }\r
   \r
-  StrCatS(*Destination, Count + 1, Source);\r
+  StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, Count);\r
   return *Destination;\r
 }\r
 \r