summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-07-28 17:13:32 +0000
committerZachary Turner <zturner@google.com>2016-07-28 17:13:32 +0000
commite78a34757eaf0ed20e30aaaef09d60b4a00ec8c2 (patch)
treeb30938be5123ae359bd8fcdf9f4a8a22f36f5691 /clang
parentd7748d649194b33bd66c2dc6e58bcf4e2b442179 (diff)
downloadbcm5719-llvm-e78a34757eaf0ed20e30aaaef09d60b4a00ec8c2.tar.gz
bcm5719-llvm-e78a34757eaf0ed20e30aaaef09d60b4a00ec8c2.zip
[Driver] Fix Windows SDK Detection
This fixes a couple of bugs in Windows SDK Detection. 1. `readFullStringValue` returns a bool, but was being compared with ERROR_SUCCESS. 2. `RegQueryValueExW` might return the null terminator in the queried value which will result in incorrect values being returned from `getSystemRegistryString`. Patch By: comicfans44@gmail.com Reviewed By: zturner Differential Revision: http://reviews.llvm.org/D21946 llvm-svn: 277005
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Driver/MSVCToolChain.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Driver/MSVCToolChain.cpp b/clang/lib/Driver/MSVCToolChain.cpp
index 62a2ea6adc7..f6d654458d4 100644
--- a/clang/lib/Driver/MSVCToolChain.cpp
+++ b/clang/lib/Driver/MSVCToolChain.cpp
@@ -114,6 +114,9 @@ static bool readFullStringValue(HKEY hkey, const char *valueName,
if (result == ERROR_SUCCESS) {
std::wstring WideValue(reinterpret_cast<const wchar_t *>(buffer.data()),
valueSize / sizeof(wchar_t));
+ if (valueSize && WideValue.back() == L'\0') {
+ WideValue.pop_back();
+ }
// The destination buffer must be empty as an invariant of the conversion
// function; but this function is sometimes called in a loop that passes in
// the same buffer, however. Simply clear it out so we can overwrite it.
@@ -191,8 +194,7 @@ static bool getSystemRegistryString(const char *keyPath, const char *valueName,
lResult = RegOpenKeyExA(hTopKey, bestName.c_str(), 0,
KEY_READ | KEY_WOW64_32KEY, &hKey);
if (lResult == ERROR_SUCCESS) {
- lResult = readFullStringValue(hKey, valueName, value);
- if (lResult == ERROR_SUCCESS) {
+ if (readFullStringValue(hKey, valueName, value)) {
bestValue = dvalue;
if (phValue)
*phValue = bestName;
@@ -209,8 +211,7 @@ static bool getSystemRegistryString(const char *keyPath, const char *valueName,
lResult =
RegOpenKeyExA(hRootKey, keyPath, 0, KEY_READ | KEY_WOW64_32KEY, &hKey);
if (lResult == ERROR_SUCCESS) {
- lResult = readFullStringValue(hKey, valueName, value);
- if (lResult == ERROR_SUCCESS)
+ if (readFullStringValue(hKey, valueName, value))
returnValue = true;
if (phValue)
phValue->clear();
OpenPOWER on IntegriCloud