[Scummvm-cvs-logs] SF.net SVN: scummvm:[55492] scummvm/trunk/engines/parallaction/graphics.cpp
tdhs at users.sourceforge.net
tdhs at users.sourceforge.net
Mon Jan 24 02:58:43 CET 2011
Revision: 55492
http://scummvm.svn.sourceforge.net/scummvm/?rev=55492&view=rev
Author: tdhs
Date: 2011-01-24 01:58:43 +0000 (Mon, 24 Jan 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/graphics.cpp
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2011-01-24 01:36:11 UTC (rev 55491)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2011-01-24 01:58:43 UTC (rev 55492)
@@ -1110,7 +1110,15 @@
}
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;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list