diff options
author | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-01-19 05:18:23 +0000 |
---|---|---|
committer | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-01-19 05:18:23 +0000 |
commit | a2bc29c4b140dc59b42bf948c280edb6e204b0bd (patch) | |
tree | b72ab7b56ef23d63fa39331f5677fd60ae47763e /MdePkg/Library/BasePrintLib/PrintLibInternal.c | |
parent | 3069bc194422eea310b17effd6700f6e0b5b58e8 (diff) | |
download | edk2-platforms-a2bc29c4b140dc59b42bf948c280edb6e204b0bd.tar.xz |
Fix a bug that length might be a negative value for worker function BasePrintLibFillBuffer(). In view of this, it is better to reuse for loop to fill the buffer.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7300 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BasePrintLib/PrintLibInternal.c')
-rw-r--r-- | MdePkg/Library/BasePrintLib/PrintLibInternal.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 3e1d5484a7..1c42baecfc 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -61,6 +61,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mStatusString[] = { @param EndBuffer The end of the input Buffer. No characters will be
placed after that.
@param Length Count of character to be placed into Buffer.
+ (Negative value indicates no buffer fill.)
@param Character Character to be placed into Buffer.
@param Increment Character increment in Buffer.
@@ -76,17 +77,17 @@ BasePrintLibFillBuffer ( IN INTN Increment
)
{
- UINTN FillBufferSize;
-
- if(Increment == 1) {
- FillBufferSize = MIN (Length, (EndBuffer - Buffer));
- Buffer = SetMem (Buffer, FillBufferSize, (UINT8) Character);
- } else {
- FillBufferSize = MIN (Length << 1, (EndBuffer - Buffer));
- Buffer = SetMem16 (Buffer, FillBufferSize, (UINT16) Character);
- }
+ INTN Index;
- return Buffer + FillBufferSize;
+ for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) {
+ *Buffer = (CHAR8) Character;
+ if (Increment != 1) {
+ *(Buffer + 1) = (CHAR8)(Character >> 8);
+ }
+ Buffer += Increment;
+ }
+
+ return Buffer;
}
/**
|