Avoid out-of-bounds access in V7_SMOOTH_SCROLLING_HACK mode

svn-id: r15258
This commit is contained in:
Max Horn
2004-09-24 22:31:42 +00:00
parent bad5721c63
commit 6749efe84c
3 changed files with 10 additions and 12 deletions
+7 -11
View File
@@ -232,18 +232,13 @@ void Gdi::init() {
_numStrips = _vm->_screenWidth / 8;
#ifdef V7_SMOOTH_SCROLLING_HACK
if (_vm->_version >= 7)
_numStrips += 1;
// TODO: Just increasing _numStrips isn't sufficient, and will cause
// problems in some cases. For example in In rooms which are *exactly* of
// width equal to _screenWidth, we now may cause an out-of-bounds access.
// One possible soution might be to replace _numStrips by a method
// Gdi::getNumStrips() which then returns the proper value, computed
// dynamically.
if (_vm->_version >= 7) {
//if (_vm->_screenWidth < _vm->virtscr[0].w)
_numStrips += 1;
}
#endif
}
void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int width, int height, bool twobufs,
bool scrollable) {
VirtScreen *vs = &virtscr[slot];
@@ -267,8 +262,9 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int number, int top, int
vs->bytesPerPixel = 1;
vs->pitch = width;
#ifdef V7_SMOOTH_SCROLLING_HACK
if (_version >= 7)
if (_version >= 7) {
vs->pitch += 8;
}
#endif
size = vs->pitch * vs->h;
@@ -1212,7 +1208,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
sx = 0;
}
while (numstrip && sx < _numStrips) {
while (numstrip && sx < _numStrips && x * 8 < _vm->_roomWidth) {
CHECK_HEAP;
if (y < vs->tdirty[sx])
-1
View File
@@ -272,7 +272,6 @@ protected:
public:
void init();
void updateNumStrips();
void drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height,
int stripnr, int numstrip, byte flag, StripTable *table = 0);
+3
View File
@@ -900,6 +900,9 @@ public:
protected:
/* Should be in Graphics class? */
uint16 _screenB, _screenH;
#ifdef V7_SMOOTH_SCROLLING_HACK
public: // HACK HACK HACK
#endif
int _roomHeight, _roomWidth;
public:
int _screenHeight, _screenWidth;