X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/254847461268bbc10cb90ca91d5feff411a16bc6..6f28211af2258ce0c052e5b5c1d862e7bbc8de27:/src/stc/stc.cpp diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index d3e43c21a7..c3a5c5a725 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -2547,9 +2547,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);