diff --git a/ChangeLog b/ChangeLog index b900d6212..a5d519ff3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * fix string encoding issue in alert messages * fix SSL authentication issue * deprecate std::wstring overloads. long live utf-8 * improve time-critical pieces feature (streaming) diff --git a/src/escape_string.cpp b/src/escape_string.cpp index 8b09403c8..545a4b112 100644 --- a/src/escape_string.cpp +++ b/src/escape_string.cpp @@ -589,7 +589,7 @@ namespace libtorrent std::wstring ws; libtorrent::utf8_wchar(s, ws); std::string ret; - ret.resize(ws.size() * 4); + ret.resize(ws.size() * 4 + 1); std::size_t size = WideCharToMultiByte(CP_ACP, 0, ws.c_str(), -1, &ret[0], ret.size(), NULL, NULL); if (size == std::size_t(-1)) return s; ret.resize(size); @@ -599,7 +599,7 @@ namespace libtorrent std::string convert_from_native(std::string const& s) { std::wstring ws; - ws.resize(s.size()); + ws.resize(s.size() + 1); std::size_t size = MultiByteToWideChar(CP_ACP, 0, s.c_str(), -1, &ws[0], ws.size()); if (size == std::size_t(-1)) return s; ws.resize(size);