From e114669cafeaafa73e15e251682c25fd13bc15e4 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 llvm-svn: 258911 --- clang/lib/Driver/MSVCToolChain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/MSVCToolChain.cpp b/clang/lib/Driver/MSVCToolChain.cpp index 1d2d20b..0834be7 100644 --- a/clang/lib/Driver/MSVCToolChain.cpp +++ b/clang/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.7.4