Avoid AIOOBE, again, with over large correction for nudge in corner cases

git-svn-id: https://zxing.googlecode.com/svn/trunk@2809 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-05-23 08:59:39 +00:00
parent 8968ca75ce
commit c35e8e38ea

View file

@ -149,10 +149,18 @@ public class QRCodeReader implements Reader {
// But careful that this does not sample off the edge
int nudgedTooFarRight = left + (int) ((matrixWidth - 1) * moduleSize) - (right - 1);
if (nudgedTooFarRight > 0) {
if (nudgedTooFarRight > nudge) {
// Neither way fits; abort
throw NotFoundException.getNotFoundInstance();
}
left -= nudgedTooFarRight;
}
int nudgedTooFarDown = top + (int) ((matrixHeight - 1) * moduleSize) - (bottom - 1);
if (nudgedTooFarDown > 0) {
if (nudgedTooFarDown > nudge) {
// Neither way fits; abort
throw NotFoundException.getNotFoundInstance();
}
top -= nudgedTooFarDown;
}