Explorar o código

Fix buffer overflow in debug printing. (#2248)

Tristan Labelle %!s(int64=6) %!d(string=hai) anos
pai
achega
f749543a76
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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);