aboutsummaryrefslogtreecommitdiff
path: root/engines/hopkins
diff options
context:
space:
mode:
authorStrangerke2013-03-31 23:45:48 +0200
committerStrangerke2013-03-31 23:45:48 +0200
commit3583a1cdc4ae922a4d9eb8745c3b21a2f7e9e91d (patch)
treea51edb22037d679708912cfac064735947c8e760 /engines/hopkins
parentbcdd8f43cd126253069a111ecb62c5137ec033ca (diff)
downloadscummvm-rg350-3583a1cdc4ae922a4d9eb8745c3b21a2f7e9e91d.tar.gz
scummvm-rg350-3583a1cdc4ae922a4d9eb8745c3b21a2f7e9e91d.tar.bz2
scummvm-rg350-3583a1cdc4ae922a4d9eb8745c3b21a2f7e9e91d.zip
HOPKINS: Fix invalid read reported by Valgrind. Thanks Eriktorbjorn for the help
Diffstat (limited to 'engines/hopkins')
-rw-r--r--engines/hopkins/lines.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 31f68d033a..f838c05436 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;