[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.324,2.325 gfx.h,1.78,1.79

Max Horn fingolfin at users.sourceforge.net
Fri Sep 24 16:30:17 CEST 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28791

Modified Files:
	gfx.cpp gfx.h 
Log Message:
Fix OOB access in V7_SMOOTH_SCROLLING_HACK mode

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.324
retrieving revision 2.325
diff -u -d -r2.324 -r2.325
--- gfx.cpp	24 Sep 2004 23:21:15 -0000	2.324
+++ gfx.cpp	24 Sep 2004 23:29:46 -0000	2.325
@@ -418,19 +418,14 @@
 	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 @@
 	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)

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- gfx.h	24 Sep 2004 22:31:33 -0000	1.78
+++ gfx.h	24 Sep 2004 23:29:46 -0000	1.79
@@ -130,7 +130,7 @@
 	 * 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 @@
 	 * 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 @@
 	 *   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;
 		}





More information about the Scummvm-git-logs mailing list