Guess of a fix at array index out of bounds problem observed in the wild

git-svn-id: https://zxing.googlecode.com/svn/trunk@1165 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-12-22 12:19:31 +00:00
parent 2736b6e19e
commit 18002649eb

View file

@ -263,13 +263,13 @@ public class Detector {
// "to" should the be the first value not included, so, the first value off
// the edge is -1
otherToX = -1;
} else if (otherToX >= image.getWidth()) {
} else if (otherToX > image.getWidth()) {
otherToX = image.getWidth();
}
int otherToY = fromY - (toY - fromY);
if (otherToY < 0) {
otherToY = -1;
} else if (otherToY >= image.getHeight()) {
} else if (otherToY > image.getHeight()) {
otherToY = image.getHeight();
}
result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
@ -326,6 +326,9 @@ public class Detector {
if (error > 0) {
y += ystep;
error -= dx;
if (y == toY) {
break;
}
}
}
int diffX = toX - fromX;