X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d1214cd7298f63d03b8f3686524c5f227fcd242..ccc040255c07064f2ed96f1a345d21860b202cb6:/src/common/file.cpp diff --git a/src/common/file.cpp b/src/common/file.cpp index b2cd1bed5f..f9badf5395 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -295,7 +295,7 @@ bool wxFile::ReadAll(wxString *str, const wxMBConv& conv) { wxCHECK_MSG( str, false, wxS("Output string must be non-NULL") ); - size_t length = wx_truncate_cast(size_t, Length()); + ssize_t length = Length(); wxCHECK_MSG( (wxFileOffset)length == Length(), false, wxT("huge file not supported") ); wxCharBuffer buf(length); @@ -309,6 +309,10 @@ bool wxFile::ReadAll(wxString *str, const wxMBConv& conv) return false; p += nread; + if ( length <= nread ) + break; + + length -= nread; } *p = 0;