X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1c26fbe00e29543f772f31afbb8017c40bb5fd95..1fa6ebf70668032c517dc32e94b8f27ef3c3e6b7:/src/stc/stc.cpp.in diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 473e08d38e..a859ec1a47 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -358,8 +358,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);