summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-01-19 05:18:23 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-01-19 05:18:23 +0000
commita2bc29c4b140dc59b42bf948c280edb6e204b0bd (patch)
treeb72ab7b56ef23d63fa39331f5677fd60ae47763e /MdePkg
parent3069bc194422eea310b17effd6700f6e0b5b58e8 (diff)
downloadedk2-a2bc29c4b140dc59b42bf948c280edb6e204b0bd.tar.gz
edk2-a2bc29c4b140dc59b42bf948c280edb6e204b0bd.tar.bz2
edk2-a2bc29c4b140dc59b42bf948c280edb6e204b0bd.zip
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')
-rw-r--r--MdePkg/Library/BasePrintLib/BasePrintLib.inf1
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.c21
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.h2
3 files changed, 12 insertions, 12 deletions
diff --git a/MdePkg/Library/BasePrintLib/BasePrintLib.inf b/MdePkg/Library/BasePrintLib/BasePrintLib.inf
index 21d6c20a45..7ff42b1f66 100644
--- a/MdePkg/Library/BasePrintLib/BasePrintLib.inf
+++ b/MdePkg/Library/BasePrintLib/BasePrintLib.inf
@@ -40,4 +40,3 @@
[LibraryClasses]
DebugLib
BaseLib
- BaseMemoryLib
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;
}
/**
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
index 151ea61898..f18ef3961e 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
@@ -19,7 +19,6 @@
#include <Library/PrintLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
//
@@ -118,6 +117,7 @@ BasePrintLibSPrint (
@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.