]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BasePrintLib: Do not do operations with NULL
authorHarry Liebel <Harry.Liebel@arm.com>
Wed, 9 Jul 2014 09:10:44 +0000 (09:10 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 9 Jul 2014 09:10:44 +0000 (09:10 +0000)
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

MdePkg/Library/BasePrintLib/PrintLibInternal.c

index c4fd755eec029a4bd02f717c0bddc44a1992041e..e61aed9fda649c9ed279445b22d15c0961b4eb6e 100644 (file)
@@ -373,17 +373,21 @@ BasePrintLibSPrintMarker (
   }\r
 \r
   LengthToReturn = 0;\r
+  EndBuffer = NULL;\r
+  OriginalBuffer = NULL;\r
 \r
   //\r
   // Reserve space for the Null terminator.\r
   //\r
-  BufferSize--;\r
-  OriginalBuffer = Buffer;\r
+  if (Buffer != NULL) {\r
+    BufferSize--;\r
+    OriginalBuffer = Buffer;\r
 \r
-  //\r
-  // Set the tag for the end of the input Buffer.\r
-  //\r
-  EndBuffer      = Buffer + BufferSize * BytesPerOutputCharacter;\r
+    //\r
+    // Set the tag for the end of the input Buffer.\r
+    //\r
+    EndBuffer = Buffer + BufferSize * BytesPerOutputCharacter;\r
+  }\r
 \r
   if ((Flags & FORMAT_UNICODE) != 0) {\r
     //\r
@@ -411,7 +415,10 @@ BasePrintLibSPrintMarker (
   //\r
   // Loop until the end of the format string is reached or the output buffer is full\r
   //\r
-  while (FormatCharacter != 0 && Buffer < EndBuffer) {\r
+  while (FormatCharacter != 0) {\r
+    if ((Buffer != NULL) && (Buffer >= EndBuffer)) {\r
+      break;\r
+    }\r
     //\r
     // Clear all the flag bits except those that may have been passed in\r
     //\r