X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/80fdcdb90ef779185492dab676d461fc34933312..8472511246c9160d4ff40ab86f635fc67c10b54a:/src/common/ffile.cpp?ds=sidebyside diff --git a/src/common/ffile.cpp b/src/common/ffile.cpp index 5212066a63..932498efcd 100644 --- a/src/common/ffile.cpp +++ b/src/common/ffile.cpp @@ -102,12 +102,12 @@ bool wxFFile::ReadAll(wxString *str, const wxMBConv& conv) clearerr(m_fp); - wxCharBuffer buf(length + 1); + wxCharBuffer buf(length); // note that real length may be less than file length for text files with DOS EOLs // ('\r's get dropped by CRT when reading which means that we have // realLen = fileLen - numOfLinesInTheFile) - length = fread(buf.data(), sizeof(char), length, m_fp); + length = fread(buf.data(), 1, length, m_fp); if ( Error() ) { @@ -117,7 +117,9 @@ bool wxFFile::ReadAll(wxString *str, const wxMBConv& conv) } buf.data()[length] = 0; - *str = wxString(buf, conv); + + wxString strTmp(buf, conv); + str->swap(strTmp); return true; }