diff options
author | Max Horn | 2004-09-24 23:29:46 +0000 |
---|---|---|
committer | Max Horn | 2004-09-24 23:29:46 +0000 |
commit | 360e189fc0b94a8e4aefd1a363f7d51f8e5df252 (patch) | |
tree | 4e5eb2d1e29e3dfddbf8849e7312dce697ed369e | |
parent | 216aa7319313fbce26aa3dff7378b178f4723027 (diff) | |
download | scummvm-rg350-360e189fc0b94a8e4aefd1a363f7d51f8e5df252.tar.gz scummvm-rg350-360e189fc0b94a8e4aefd1a363f7d51f8e5df252.tar.bz2 scummvm-rg350-360e189fc0b94a8e4aefd1a363f7d51f8e5df252.zip |
Fix OOB access in V7_SMOOTH_SCROLLING_HACK mode
svn-id: r15260
-rw-r--r-- | scumm/gfx.cpp | 12 | ||||
-rw-r--r-- | scumm/gfx.h | 6 |
2 files changed, 8 insertions, 10 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 31872e83e1..781798a615 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -418,19 +418,14 @@ void Gdi::updateDirtyScreen(VirtScreen *vs) { int i; int w = 8; int start = 0; -#ifdef V7_SMOOTH_SCROLLING_HACK - const int numStrips = MIN(_vm->_screenStartStrip + _numStrips, _vm->_roomWidth / 8) - _vm->_screenStartStrip; -#else - const int numStrips = _numStrips; -#endif - for (i = 0; i < numStrips; i++) { + for (i = 0; i < _numStrips; i++) { if (vs->bdirty[i]) { const int top = vs->tdirty[i]; const int bottom = vs->bdirty[i]; vs->tdirty[i] = vs->h; vs->bdirty[i] = 0; - if (i != (numStrips - 1) && vs->bdirty[i + 1] == bottom && vs->tdirty[i + 1] == top) { + if (i != (_numStrips - 1) && vs->bdirty[i + 1] == bottom && vs->tdirty[i + 1] == top) { // Simple optimizations: if two or more neighbouring strips // form one bigger rectangle, coalesce them. w += 8; @@ -462,6 +457,9 @@ void Gdi::drawStripToScreen(VirtScreen *vs, int x, int width, int top, int botto assert(x >= 0 && width <= vs->pitch); assert(_textSurface.pixels); assert(_compositeBuf); + + if (width > vs->w); + width = vs->w; // Clip to the visible part of the scene if (top < _vm->_screenTop) diff --git a/scumm/gfx.h b/scumm/gfx.h index 8ae09d136b..47db62f08e 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -130,7 +130,7 @@ struct VirtScreen : Graphics::Surface { * This together with bdirty is used to do efficient redrawing of * the screen. */ - uint16 tdirty[80]; + uint16 tdirty[80 + 1]; /** * Array containing for each visible strip of this virtual screen the @@ -139,7 +139,7 @@ struct VirtScreen : Graphics::Surface { * This together with tdirty is used to do efficient redrawing of * the screen. */ - uint16 bdirty[80]; + uint16 bdirty[80 + 1]; /** * Convenience method to set the whole tdirty and bdirty arrays to one @@ -150,7 +150,7 @@ struct VirtScreen : Graphics::Surface { * vs->setDirtyRange(0, 0); */ void setDirtyRange(int top, int bottom) { - for (int i = 0; i < 80; i++) { + for (int i = 0; i < 80 + 1; i++) { tdirty[i] = top; bdirty[i] = bottom; } |