Make bounds errors fatal

This commit is contained in:
Phillip Stephens 2016-09-04 13:30:15 -07:00
parent cd9aa3eaf4
commit 94dc1e46fa
1 changed files with 8 additions and 4 deletions

View File

@ -76,7 +76,8 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin)
if ((position < 0 || (atInt64)position > (atInt64)m_length)) if ((position < 0 || (atInt64)position > (atInt64)m_length))
{ {
if (m_globalErr) if (m_globalErr)
atError("Position %0.8X outside stream bounds ", position); atFatal("Position %0.8X outside stream bounds ", position);
m_position = m_length;
setError(); setError();
return; return;
} }
@ -88,7 +89,8 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin)
if ((((atInt64)m_position + position) < 0 || (m_position + position) > m_length)) if ((((atInt64)m_position + position) < 0 || (m_position + position) > m_length))
{ {
if (m_globalErr) if (m_globalErr)
atError("Position %0.8X outside stream bounds ", position); atFatal("Position %0.8X outside stream bounds ", position);
m_position = m_length;
setError(); setError();
return; return;
} }
@ -100,7 +102,8 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin)
if ((((atInt64)m_length - position < 0) || (m_length - position) > m_length)) if ((((atInt64)m_length - position < 0) || (m_length - position) > m_length))
{ {
if (m_globalErr) if (m_globalErr)
atError("Position %0.8X outside stream bounds ", position); atFatal("Position %0.8X outside stream bounds ", position);
m_position = m_length;
setError(); setError();
return; return;
} }
@ -142,7 +145,8 @@ atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length)
if (m_position + length > m_length) if (m_position + length > m_length)
{ {
if (m_globalErr) if (m_globalErr)
atError("Position %0.8X outside stream bounds ", m_position); atFatal("Position %0.8X outside stream bounds ", m_position);
m_position = m_length;
setError(); setError();
return 0; return 0;
} }