X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f8a586e08eef0a5d09612f26f0e0c687cfac9963..ade0e73d18274cac0a51095fe84f49bd60526b56:/src/common/wfstream.cpp diff --git a/src/common/wfstream.cpp b/src/common/wfstream.cpp index e40bc2fcfa..af90722dd0 100644 --- a/src/common/wfstream.cpp +++ b/src/common/wfstream.cpp @@ -236,7 +236,8 @@ size_t wxFFileInputStream::OnSysRead(void *buffer, size_t size) { ssize_t ret = m_file->Read(buffer, size); - if (m_file->Eof()) + // It is not safe to call Eof() if the file is not opened. + if (!m_file->IsOpened() || m_file->Eof()) m_lasterror = wxSTREAM_EOF; if (ret == wxInvalidOffset) { @@ -252,7 +253,8 @@ wxFileOffset wxFFileInputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode) #ifdef __VMS #pragma message disable intsignchange #endif - return ( m_file->Seek(pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset ); + wxASSERT_MSG( pos >= LONG_MIN && pos <= LONG_MAX, _T("no huge wxFFile support") ); + return ( m_file->Seek((long)pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset ); #ifdef __VMS #pragma message enable intsignchange #endif @@ -314,7 +316,8 @@ wxFFileOutputStream::~wxFFileOutputStream() size_t wxFFileOutputStream::OnSysWrite(const void *buffer, size_t size) { size_t ret = m_file->Write(buffer, size); - if (m_file->Error()) + // It is not safe to call Error() if the file is not opened. + if (!m_file->IsOpened() || m_file->Error()) m_lasterror = wxSTREAM_WRITE_ERROR; else m_lasterror = wxSTREAM_NO_ERROR; @@ -331,7 +334,8 @@ wxFileOffset wxFFileOutputStream::OnSysSeek(wxFileOffset pos, wxSeekMode mode) #ifdef __VMS #pragma message disable intsignchange #endif - return ( m_file->Seek(pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset ); + wxASSERT_MSG( pos >= LONG_MIN && pos <= LONG_MAX, _T("no huge wxFFile support") ); + return ( m_file->Seek((long)pos, mode) ? (wxFileOffset)m_file->Tell() : wxInvalidOffset ); #ifdef __VMS #pragma message enable intsignchange #endif