Handle strings with embedded NULs in wxDataStream

Read/write the entire string and not just the part until the first NUL in it.

Closes #17556.
This commit is contained in:
Vadim Zeitlin
2016-06-04 21:47:12 +02:00
parent 889cbd8e04
commit d68eb10e3d
3 changed files with 19 additions and 2 deletions

View File

@@ -187,7 +187,7 @@ wxString wxDataInputStream::ReadString()
if ( tmp )
{
m_input->Read(tmp.data(), len);
ret = m_conv->cMB2WX(tmp.data());
ret = m_conv->cMB2WC(tmp.data(), len, NULL);
}
#else
wxStringBuffer buf(ret, len);
@@ -590,10 +590,11 @@ void wxDataOutputStream::WriteString(const wxString& string)
{
#if wxUSE_UNICODE
const wxWX2MBbuf buf = string.mb_str(*m_conv);
size_t len = buf.length();
#else
const wxWX2MBbuf buf = string.mb_str();
size_t len = string.size();
#endif
size_t len = strlen(buf);
Write32(len);
if (len > 0)
m_output->Write(buf, len);