]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/SimpleFileParsing.c
BaseTools/header.makefile: revert gcc-8 "-Wno-xxx" options on OSX
[mirror_edk2.git] / BaseTools / Source / C / Common / SimpleFileParsing.c
index 868c6b794b99fa240a31e884131671b0e1b16f33..209a0954b3f22031b98daab3e51e309c7eb59b6f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Generic but simple file parsing routines.\r
 \r
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -1232,12 +1232,10 @@ GetHexChars (
 {\r
   UINT32  Len;\r
   Len = 0;\r
-  while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) {\r
+  while (!EndOfFile (&mGlobals.SourceFile) && (Len < BufferLen)) {\r
     if (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {\r
-      *Buffer = mGlobals.SourceFile.FileBufferPtr[0];\r
-      Buffer++;\r
+      Buffer[Len] = mGlobals.SourceFile.FileBufferPtr[0];\r
       Len++;\r
-      BufferLen--;\r
       mGlobals.SourceFile.FileBufferPtr++;\r
     } else {\r
       break;\r
@@ -1246,8 +1244,8 @@ GetHexChars (
   //\r
   // Null terminate if we can\r
   //\r
-  if ((Len > 0) && (BufferLen > 0)) {\r
-    *Buffer = 0;\r
+  if ((Len > 0) && (Len < BufferLen)) {\r
+    Buffer[Len] = 0;\r
   }\r
 \r
   return Len;\r