Issue #147 : handle corner case as normal failed read rather than AIOOBE

This commit is contained in:
Sean Owen 2014-05-15 13:26:04 +01:00
parent 2a8cd871bc
commit 77aabfc457

View file

@ -326,28 +326,32 @@ public final class PDF417ScanningDecoder {
throw ChecksumException.getChecksumInstance();
}
private static BarcodeValue[][] createBarcodeMatrix(DetectionResult detectionResult) {
BarcodeValue[][] barcodeMatrix = new BarcodeValue[detectionResult.getBarcodeRowCount()][detectionResult
.getBarcodeColumnCount() + 2];
private static BarcodeValue[][] createBarcodeMatrix(DetectionResult detectionResult) throws FormatException {
BarcodeValue[][] barcodeMatrix =
new BarcodeValue[detectionResult.getBarcodeRowCount()][detectionResult.getBarcodeColumnCount() + 2];
for (int row = 0; row < barcodeMatrix.length; row++) {
for (int column = 0; column < barcodeMatrix[row].length; column++) {
barcodeMatrix[row][column] = new BarcodeValue();
}
}
int column = -1;
int column = 0;
for (DetectionResultColumn detectionResultColumn : detectionResult.getDetectionResultColumns()) {
column++;
if (detectionResultColumn == null) {
continue;
}
if (detectionResultColumn != null) {
for (Codeword codeword : detectionResultColumn.getCodewords()) {
if (codeword == null || codeword.getRowNumber() == -1) {
continue;
if (codeword != null) {
int rowNumber = codeword.getRowNumber();
if (rowNumber >= 0) {
if (rowNumber >= barcodeMatrix.length) {
throw FormatException.getFormatInstance();
}
barcodeMatrix[codeword.getRowNumber()][column].setValue(codeword.getValue());
barcodeMatrix[rowNumber][column].setValue(codeword.getValue());
}
}
}
}
column++;
}
return barcodeMatrix;
}