X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d1214cd7298f63d03b8f3686524c5f227fcd242..cb04da13bddf9c70028b7adb55ac4efbb92ce4d4:/src/common/file.cpp diff --git a/src/common/file.cpp b/src/common/file.cpp index b2cd1bed5f..e553b2c833 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -295,20 +295,24 @@ 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); char* p = buf.data(); for ( ;; ) { - static const unsigned READSIZE = 4096; + static const ssize_t READSIZE = 4096; ssize_t nread = Read(p, length > READSIZE ? READSIZE : length); if ( nread == wxInvalidOffset ) return false; p += nread; + if ( length <= nread ) + break; + + length -= nread; } *p = 0;