From 29de80e87870b1e4ae297b69026517bd0ae18e55 Mon Sep 17 00:00:00 2001 From: Daniel Marjamaki Date: Wed, 27 Jan 2016 07:33:50 +0000 Subject: [PATCH] Fix array index out of bounds Differential Revision: http://reviews.llvm.org/D16582 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258911 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/MSVCToolChain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Driver/MSVCToolChain.cpp b/lib/Driver/MSVCToolChain.cpp index 1d2d20b407..0834be721e 100644 --- a/lib/Driver/MSVCToolChain.cpp +++ b/lib/Driver/MSVCToolChain.cpp @@ -141,8 +141,8 @@ static bool getSystemRegistryString(const char *keyPath, const char *valueName, nextKey++; size_t partialKeyLength = keyEnd - keyPath; char partialKey[256]; - if (partialKeyLength > sizeof(partialKey)) - partialKeyLength = sizeof(partialKey); + if (partialKeyLength >= sizeof(partialKey)) + partialKeyLength = sizeof(partialKey) - 1; strncpy(partialKey, keyPath, partialKeyLength); partialKey[partialKeyLength] = '\0'; HKEY hTopKey = NULL; -- 2.40.0