diff options
author | Harry Liebel <Harry.Liebel@arm.com> | 2014-07-09 09:10:44 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-07-09 09:10:44 +0000 |
commit | 28087ef09f3ade5072ce1505a8acc8aff85787cd (patch) | |
tree | 0f35490461e003cc666e3f32ef1d1171ea85c0cc /MdePkg/Library | |
parent | 85e2e0854bd158a561ee829d84635a1ff8128581 (diff) | |
download | edk2-platforms-28087ef09f3ade5072ce1505a8acc8aff85787cd.tar.xz |
MdePkg/BasePrintLib: Do not do operations with NULL
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Harry Liebel <Harry.Liebel@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
Reviewed-by: Gao, Liming <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15646 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library')
-rw-r--r-- | MdePkg/Library/BasePrintLib/PrintLibInternal.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index c4fd755eec..e61aed9fda 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -373,17 +373,21 @@ BasePrintLibSPrintMarker ( }
LengthToReturn = 0;
+ EndBuffer = NULL;
+ OriginalBuffer = NULL;
//
// Reserve space for the Null terminator.
//
- BufferSize--;
- OriginalBuffer = Buffer;
+ if (Buffer != NULL) {
+ BufferSize--;
+ OriginalBuffer = Buffer;
- //
- // Set the tag for the end of the input Buffer.
- //
- EndBuffer = Buffer + BufferSize * BytesPerOutputCharacter;
+ //
+ // Set the tag for the end of the input Buffer.
+ //
+ EndBuffer = Buffer + BufferSize * BytesPerOutputCharacter;
+ }
if ((Flags & FORMAT_UNICODE) != 0) {
//
@@ -411,7 +415,10 @@ BasePrintLibSPrintMarker ( //
// Loop until the end of the format string is reached or the output buffer is full
//
- while (FormatCharacter != 0 && Buffer < EndBuffer) {
+ while (FormatCharacter != 0) {
+ if ((Buffer != NULL) && (Buffer >= EndBuffer)) {
+ break;
+ }
//
// Clear all the flag bits except those that may have been passed in
//
|