[Scummvm-cvs-logs] scummvm master -> 3583a1cdc4ae922a4d9eb8745c3b21a2f7e9e91d

Strangerke Strangerke at scummvm.org
Sun Mar 31 23:46:48 CEST 2013


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3583a1cdc4 HOPKINS: Fix invalid read reported by Valgrind. Thanks Eriktorbjorn for the help


Commit: 3583a1cdc4ae922a4d9eb8745c3b21a2f7e9e91d
    https://github.com/scummvm/scummvm/commit/3583a1cdc4ae922a4d9eb8745c3b21a2f7e9e91d
Author: Strangerke (strangerke at scummvm.org)
Date: 2013-03-31T14:45:48-07:00

Commit Message:
HOPKINS: Fix invalid read reported by Valgrind. Thanks Eriktorbjorn for the help

Changed paths:
    engines/hopkins/lines.cpp



diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 31f68d0..f838c05 100644
--- a/engines/hopkins/lines.cpp
+++ b/engines/hopkins/lines.cpp
@@ -2448,19 +2448,22 @@ int LinesManager::testLine(int paramX, int paramY, int *testValue, int *foundLin
 			*foundDataIdx = collDataIdx;
 			return idx;
 		}
-		if (lineData[2 * (lineDataEndIdx - 1)] == paramX && lineData[2 * (lineDataEndIdx - 1) + 1] == paramY) {
-			*testValue = 2;
-			int posX = lineData[0];
-			int posY = lineData[1];
-			if (_lineItem[idx]._directionRouteInc == DIR_DOWN || _lineItem[idx]._directionRouteInc == DIR_UP)
-				posY -= 2;
-			if (_lineItem[idx]._directionRouteInc == DIR_RIGHT || _lineItem[idx]._directionRouteDec == DIR_LEFT)
-				posX -= 2;
-			if (!checkCollisionLine(posX, posY, &collDataIdx, &collLineIdx, 0, _lastLine))
-				error("Error in test line");
-			*foundLineIdx = collLineIdx;
-			*foundDataIdx = collDataIdx;
-			return idx;
+
+		if (lineDataEndIdx > 0) {
+			if (lineData[2 * (lineDataEndIdx - 1)] == paramX && lineData[2 * (lineDataEndIdx - 1) + 1] == paramY) {
+				*testValue = 2;
+				int posX = lineData[0];
+				int posY = lineData[1];
+				if (_lineItem[idx]._directionRouteInc == DIR_DOWN || _lineItem[idx]._directionRouteInc == DIR_UP)
+					posY -= 2;
+				if (_lineItem[idx]._directionRouteInc == DIR_RIGHT || _lineItem[idx]._directionRouteDec == DIR_LEFT)
+					posX -= 2;
+				if (!checkCollisionLine(posX, posY, &collDataIdx, &collLineIdx, 0, _lastLine))
+					error("Error in test line");
+				*foundLineIdx = collLineIdx;
+				*foundDataIdx = collDataIdx;
+				return idx;
+			}
 		}
 	}
 	return -1;






More information about the Scummvm-git-logs mailing list