Refine code to make it more safely.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15720 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Eric Dong 2014-07-30 01:19:21 +00:00 committed by ydong10
parent f9e420d5d2
commit 784952b189
1 changed files with 7 additions and 2 deletions

View File

@ -1323,6 +1323,7 @@ IfrCatenate (
UINTN Size;
UINT16 Length0;
UINT16 Length1;
UINT8 *TmpBuf;
//
// String[0] - The second string
@ -1378,8 +1379,12 @@ IfrCatenate (
Result->Buffer = AllocateZeroPool (Result->BufferLen);
ASSERT (Result->Buffer != NULL);
CopyMem (Result->Buffer, GetBufferForValue(&Value[0]), Length0);
CopyMem (&Result->Buffer[Length0], GetBufferForValue(&Value[1]), Length1);
TmpBuf = GetBufferForValue(&Value[0]);
ASSERT (TmpBuf != NULL);
CopyMem (Result->Buffer, TmpBuf, Length0);
TmpBuf = GetBufferForValue(&Value[1]);
ASSERT (TmpBuf != NULL);
CopyMem (&Result->Buffer[Length0], TmpBuf, Length1);
}
Done:
if (Value[0].Buffer != NULL) {