Bugfix UPCAReader: The maybeReturnResult function checks whether the Result

is UPCA or EAN13. The old version returned an uninitialised Ref<Result>
(at the EAN13 case) which let MultiFormatUPCEANReader::decodeRow (line 90)
crash because a Result is assumed.

The bugfix is technically oriented at the java version.

Note: This error doesn't appear at normal tests because the MultiFormatUPCEANReader
uses the EAN13 reader for UPC-A detection. The UPCAReader is only used if
DecodeHints BarcodeFormat::UPC_A ist set.
This commit is contained in:
SebGDev 2015-01-20 14:28:17 +01:00
parent 9cba60be8f
commit 975b67b248

View File

@ -19,7 +19,7 @@
*/
#include "UPCAReader.h"
#include <zxing/ReaderException.h>
#include <zxing/FormatException.h>
using zxing::oned::UPCAReader;
using zxing::Ref;
@ -29,6 +29,7 @@ using zxing::Result;
using zxing::BitArray;
using zxing::BinaryBitmap;
using zxing::DecodeHints;
using zxing::FormatException;
UPCAReader::UPCAReader() : ean13Reader() {}
@ -53,17 +54,15 @@ int UPCAReader::decodeMiddle(Ref<BitArray> row,
}
Ref<Result> UPCAReader::maybeReturnResult(Ref<Result> result) {
if (result.empty()) {
return result;
}
const std::string& text = (result->getText())->getText();
if (text[0] == '0') {
Ref<String> resultString(new String(text.substr(1)));
Ref<Result> res(new Result(resultString, result->getRawBytes(), result->getResultPoints(),
BarcodeFormat::UPC_A));
return res;
} else {
throw FormatException();
}
return Ref<Result>();
}
zxing::BarcodeFormat UPCAReader::getBarcodeFormat(){