From 39a16cb41d0f31923a88b0e50761fb7d4a14729a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 4 Mar 2000 20:37:16 +0000 Subject: [PATCH] fixed wxDataInputStream::ReadString for empty strings git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6442 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datstrm.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/common/datstrm.cpp b/src/common/datstrm.cpp index 5c4fd46091..d6f97b7e65 100644 --- a/src/common/datstrm.cpp +++ b/src/common/datstrm.cpp @@ -90,19 +90,23 @@ wxString wxDataInputStream::ReadString() len = Read32(); + if (len > 0) + { #if wxUSE_UNICODE - char *tmp = new char[len + 1]; - m_input->Read(tmp, len); - tmp[len] = 0; - wxString s(tmp); - delete[] tmp; + char *tmp = new char[len + 1]; + m_input->Read(tmp, len); + tmp[len] = 0; + wxString s(tmp); + delete[] tmp; #else - wxString s; - m_input->Read(s.GetWriteBuf(len), len); - s.UngetWriteBuf(); + wxString s; + m_input->Read(s.GetWriteBuf(len), len); + s.UngetWriteBuf(); #endif - - return s; + return s; + } + else + return wxEmptyString; } wxDataInputStream& wxDataInputStream::operator>>(wxString& s) @@ -203,8 +207,9 @@ void wxDataOutputStream::Write8(wxUint8 i) void wxDataOutputStream::WriteString(const wxString& string) { const wxWX2MBbuf buf = string.mb_str(); - Write32(string.Length()); - m_output->Write(buf, string.Len()); + Write32(string.Len()); + if (string.Len() > 0) + m_output->Write(buf, string.Len()); } // Must be at global scope for VC++ 5