mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Issue #67 : Avoid rare AIOOBE on PDF417 misread
This commit is contained in:
parent
bd4536f077
commit
1b898320ac
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.google.zxing.pdf417.decoder;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.pdf417.PDF417Common;
|
||||
|
||||
|
@ -110,7 +111,7 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
|
|||
return (int) (averageRowHeight + 0.5);
|
||||
}
|
||||
|
||||
int[] getRowHeights() {
|
||||
int[] getRowHeights() throws FormatException {
|
||||
BarcodeMetadata barcodeMetadata = getBarcodeMetadata();
|
||||
if (barcodeMetadata == null) {
|
||||
return null;
|
||||
|
@ -119,8 +120,12 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
|
|||
int[] result = new int[barcodeMetadata.getRowCount()];
|
||||
for (Codeword codeword : getCodewords()) {
|
||||
if (codeword != null) {
|
||||
result[codeword.getRowNumber()]++;
|
||||
}
|
||||
int rowNumber = codeword.getRowNumber();
|
||||
if (rowNumber >= result.length) {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
result[rowNumber]++;
|
||||
} // else throw exception?
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public final class PDF417ScanningDecoder {
|
|||
|
||||
private static DetectionResult merge(DetectionResultRowIndicatorColumn leftRowIndicatorColumn,
|
||||
DetectionResultRowIndicatorColumn rightRowIndicatorColumn)
|
||||
throws NotFoundException {
|
||||
throws NotFoundException, FormatException {
|
||||
if (leftRowIndicatorColumn == null && rightRowIndicatorColumn == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public final class PDF417ScanningDecoder {
|
|||
}
|
||||
|
||||
private static BoundingBox adjustBoundingBox(DetectionResultRowIndicatorColumn rowIndicatorColumn)
|
||||
throws NotFoundException {
|
||||
throws NotFoundException, FormatException {
|
||||
if (rowIndicatorColumn == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue