Fixed handling of reading strings from the registry. This was
broken when support for binary data was added. The terminating NUL was included in the string as a character (that's in addition to the terminating NUL added by std::string).
This commit is contained in:
parent
8d99fd2511
commit
ab11ebea01
|
@ -222,6 +222,11 @@ CArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR* name, DWORD type)
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if zero size then return empty string
|
||||||
|
if (size == 0) {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
// allocate space
|
// allocate space
|
||||||
char* buffer = new char[size];
|
char* buffer = new char[size];
|
||||||
|
|
||||||
|
@ -234,6 +239,10 @@ CArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR* name, DWORD type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up and return value
|
// clean up and return value
|
||||||
|
if (type == REG_SZ && buffer[size - 1] == '\0') {
|
||||||
|
// don't include terminating nul; std::string will add one.
|
||||||
|
--size;
|
||||||
|
}
|
||||||
std::string value(buffer, size);
|
std::string value(buffer, size);
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
return value;
|
return value;
|
||||||
|
|
Loading…
Reference in New Issue