]> granicus.if.org Git - clang/commitdiff
Fix array index out of bounds
authorDaniel Marjamaki <daniel.marjamaki@evidente.se>
Wed, 27 Jan 2016 07:33:50 +0000 (07:33 +0000)
committerDaniel Marjamaki <daniel.marjamaki@evidente.se>
Wed, 27 Jan 2016 07:33:50 +0000 (07:33 +0000)
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

index 1d2d20b40727908f277358b7c1f3142ea15380d2..0834be721e155cd24599c23cbce8bd175760b3ea 100644 (file)
@@ -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;