mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
3069bc1944
commit
a2bc29c4b1
|
@ -40,4 +40,3 @@
|
||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
DebugLib
|
DebugLib
|
||||||
BaseLib
|
BaseLib
|
||||||
BaseMemoryLib
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mStatusString[] = {
|
||||||
@param EndBuffer The end of the input Buffer. No characters will be
|
@param EndBuffer The end of the input Buffer. No characters will be
|
||||||
placed after that.
|
placed after that.
|
||||||
@param Length Count of character to be placed into Buffer.
|
@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 Character Character to be placed into Buffer.
|
||||||
@param Increment Character increment in Buffer.
|
@param Increment Character increment in Buffer.
|
||||||
|
|
||||||
|
@ -76,17 +77,17 @@ BasePrintLibFillBuffer (
|
||||||
IN INTN Increment
|
IN INTN Increment
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN FillBufferSize;
|
INTN Index;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <Library/PrintLib.h>
|
#include <Library/PrintLib.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/DebugLib.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
|
@param EndBuffer The end of the input Buffer. No characters will be
|
||||||
placed after that.
|
placed after that.
|
||||||
@param Length Count of character to be placed into Buffer.
|
@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 Character Character to be placed into Buffer.
|
||||||
@param Increment Character increment in Buffer.
|
@param Increment Character increment in Buffer.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue