- ret = m_file->Read(buffer, size);
-
- if (m_file->Eof())
- m_lasterror = wxStream_EOF;
- if (ret == wxInvalidOffset)
+ // 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)