diff options
author | David Turner | 2011-01-24 01:58:43 +0000 |
---|---|---|
committer | David Turner | 2011-01-24 01:58:43 +0000 |
commit | 0f07082a78355b8607bf04dd4e1ba42e14fc636f (patch) | |
tree | 48cc83741f154fae47753624b9e4ff9b78891edf /engines | |
parent | 9961e054d0b5b7d301eabdfdc54549609b49dbcf (diff) | |
download | scummvm-rg350-0f07082a78355b8607bf04dd4e1ba42e14fc636f.tar.gz scummvm-rg350-0f07082a78355b8607bf04dd4e1ba42e14fc636f.tar.bz2 scummvm-rg350-0f07082a78355b8607bf04dd4e1ba42e14fc636f.zip |
PARALLACTION: Improve safety of PathBuffer::getValue().
This will now avoid invalid memory reads and instead emit warnings if it is called with values outside of the expected data buffer or on a NULL buffer.
svn-id: r55492
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/graphics.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 2990d024d2..0e6f10f6af 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -1110,7 +1110,15 @@ void PathBuffer::free() { } byte PathBuffer::getValue(uint16 x, uint16 y) const { - byte m = data[(x >> 3) + y * internalWidth]; + byte m = 0; + if (data) { + uint index = (x >> 3) + y * internalWidth; + if (index < size) + m = data[index]; + else + warning("PathBuffer::getValue(x: %d, y: %d) outside of data buffer of size %d", x, y, size); + } else + warning("PathBuffer::getValue() attempted to use NULL data buffer"); uint bit = bigEndian ? (x & 7) : (7 - (x & 7)); return ((1 << bit) & m) >> bit; } |