Browse Source

Fix buffer overflow in debug printing. (#2248)

Tristan Labelle 6 years ago
parent
commit
f749543a76
1 changed files with 1 additions and 1 deletions
  1. 1 1
      lib/Support/Debug.cpp

+ 1 - 1
lib/Support/Debug.cpp

@@ -85,7 +85,7 @@ namespace llvm {
         // Need a null-terminated string here.
         char chunk[512];
         while (Size > 0) {
-          size_t len = (Size < _countof(chunk) ? Size : _countof(chunk));
+          size_t len = std::min(Size, _countof(chunk) - 1);
           memcpy(chunk, Ptr, len);
           chunk[len] = '\0';
           OutputDebugStringA(chunk);