forked from 0ad/0ad
Fixes instant multiplayer crash on OS X Lion (10.7). libc++ had a bug where it set eofbit on reading the last character in a stringstream, we compare gcount with the expected length as a workaround to detect real eofs. Fixes #3109.
This was SVN commit r16714.
This commit is contained in:
parent
6506bc20cb
commit
f6f4f83784
@ -81,8 +81,14 @@ void CStdDeserializer::Get(const char* name, u8* data, size_t len)
|
||||
UNUSED2(name);
|
||||
#endif
|
||||
m_Stream.read((char*)data, (std::streamsize)len);
|
||||
if (!m_Stream.good()) // hit eof before len, or other errors
|
||||
throw PSERROR_Deserialize_ReadFailed();
|
||||
if (!m_Stream.good())
|
||||
{
|
||||
// hit eof before len, or other errors
|
||||
// Note: older libc++ versions incorrectly set eofbit on the last char; test gcount as a workaround
|
||||
// see https://llvm.org/bugs/show_bug.cgi?id=9335
|
||||
if (m_Stream.bad() || m_Stream.fail() || (m_Stream.eof() && m_Stream.gcount() != (std::streamsize)len))
|
||||
throw PSERROR_Deserialize_ReadFailed();
|
||||
}
|
||||
}
|
||||
|
||||
std::istream& CStdDeserializer::GetStream()
|
||||
|
Loading…
Reference in New Issue
Block a user