mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
Avoid out-of-bounds access in V7_SMOOTH_SCROLLING_HACK mode
svn-id: r15258
This commit is contained in:
+7
-11
@@ -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])
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user