summaryrefslogtreecommitdiff
path: root/src/shared/util.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-11-05 23:48:06 +0100
committerTannin <devnull@localhost>2014-11-05 23:48:06 +0100
commit7a7c464b18f2977c3a7aa7e80c4041732b19ba26 (patch)
treed1740340efbed742e3e83b71ce329f4d61c29e38 /src/shared/util.cpp
parenta62ecc5bf1e92e6dd2ba8e6e61a797641c254d92 (diff)
- archive library can now query for password during extraction (seems to be necessary for rars)
- process blacklist is now taken from a file if there is one, not hardcoded - removed workaround for the papyrus compiler - updated loot client to work with the actual api - loot client now links with loot32.dll at runtime - loot client now produces its output in a (json-)file which includes all plugin messages and dirty flags - fomod installer now tries to parse the xml with several encodings - fomod installer will now display a diagnostics warning if the jpg imageformat isn't supported - base preview plugin now tries to be a bit smarter about resizing images to fit the screen - bugfix: fomod installer no longer tries to open an image even after detecting its invalid - bugfix: potential null-pointer dereferentiation in getprivateprofile... hooks - bugfix: potential null-pointer dereferentiation in download manager - bugfix: internal origin name showed up in one more place - bugfix: ToString function produced strings that were one (zero-termination-)character too long
Diffstat (limited to 'src/shared/util.cpp')
-rw-r--r--src/shared/util.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index 4bc5a8a4..d4a77929 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -71,7 +71,9 @@ std::string ToString(const std::wstring &source, bool utf8)
if (sizeRequired == 0) {
throw windows_error("failed to convert string to multibyte");
}
- result.resize(sizeRequired, '\0');
+ // the size returned by WideCharToMultiByte contains zero termination IF -1 is specified for the length.
+ // we don't want that \0 in the string because then the length field would be wrong. Because madness
+ result.resize(sizeRequired - 1, '\0');
::WideCharToMultiByte(codepage, 0, &source[0], (int)source.size(), &result[0], sizeRequired, NULL, NULL);
return result;
}
@@ -117,14 +119,15 @@ std::wstring ToLower(const std::wstring &text)
VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName)
{
- DWORD size = ::GetFileVersionInfoSizeW(fileName.c_str(), NULL);
+ DWORD handle;
+ DWORD size = ::GetFileVersionInfoSizeW(fileName.c_str(), &handle);
if (size == 0) {
throw windows_error("failed to determine file version info size");
}
void *buffer = new char[size];
try {
- if (!::GetFileVersionInfoW(fileName.c_str(), 0UL, size, buffer)) {
+ if (!::GetFileVersionInfoW(fileName.c_str(), handle, size, buffer)) {
throw windows_error("failed to determine file version info");
}