X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/254847461268bbc10cb90ca91d5feff411a16bc6..1fa6ebf70668032c517dc32e94b8f27ef3c3e6b7:/src/stc/stc.cpp.in diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 7459ffa401..a859ec1a47 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -356,9 +356,12 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) if (len > 0) { #if wxUSE_UNICODE - wxMemoryBuffer buffer(len); + wxMemoryBuffer buffer(len+1); success = (file.Read(buffer.GetData(), len) == len); - contents = wxString(buffer, *wxConvCurrent); + if (success) { + ((char*)buffer.GetData())[len] = 0; + contents = wxString(buffer, *wxConvCurrent, len); + } #else wxString buffer; success = (file.Read(wxStringBuffer(buffer, len), len) == len);