]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c
MdeModulePkg/DxePrintLibPrint2Protocol: Fix error in Precision position calculation
[mirror_edk2.git] / MdeModulePkg / Library / DxePrintLibPrint2Protocol / PrintLib.c
index 56534e56c3a1e06d554561caf99b5d5e8de9ed80..570d06d82e849461572774133aeea794a2c62217 100644 (file)
@@ -2050,7 +2050,10 @@ InternalPrintLibSPrintMarker (
       // Compute the number of characters in ArgumentString and store it in Count\r
       // ArgumentString is either null-terminated, or it contains Precision characters\r
       //\r
-      for (Count = 0; Count < Precision || ((Flags & PRECISION) == 0); Count++) {\r
+      for (Count = 0;\r
+            ArgumentString[Count * BytesPerArgumentCharacter] != '\0' &&\r
+            Count < Precision || ((Flags & PRECISION) == 0);\r
+            Count++) {\r
         ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;\r
         if (ArgumentCharacter == 0) {\r
           break;\r
@@ -2107,7 +2110,7 @@ InternalPrintLibSPrintMarker (
     //\r
     // Copy the string into the output buffer performing the required type conversions\r
     //\r
-    while (Index < Count) {\r
+    while (Index < Count && (*ArgumentString) != '\0') {\r
       ArgumentCharacter = ((*ArgumentString & 0xff) | (((UINT8)*(ArgumentString + 1)) << 8)) & ArgumentMask;\r
 \r
       LengthToReturn += (1 * BytesPerOutputCharacter);\r