X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1c26fbe00e29543f772f31afbb8017c40bb5fd95..f2aa588ba5c2e316d87105da86e0ebe8bbeac5df:/src/stc/stc.cpp?ds=sidebyside diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index efedc9d763..c3a5c5a725 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -2549,8 +2549,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) #if wxUSE_UNICODE wxMemoryBuffer buffer(len+1); success = (file.Read(buffer.GetData(), len) == len); - ((char*)buffer.GetData())[len] = 0; - 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);