From 975b67b248ed52fe66de7de01baa53fa95fb0126 Mon Sep 17 00:00:00 2001 From: SebGDev Date: Tue, 20 Jan 2015 14:28:17 +0100 Subject: [PATCH] Bugfix UPCAReader: The maybeReturnResult function checks whether the Result is UPCA or EAN13. The old version returned an uninitialised Ref (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. --- core/src/zxing/oned/UPCAReader.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/zxing/oned/UPCAReader.cpp b/core/src/zxing/oned/UPCAReader.cpp index 38ca507..47efb0f 100644 --- a/core/src/zxing/oned/UPCAReader.cpp +++ b/core/src/zxing/oned/UPCAReader.cpp @@ -19,7 +19,7 @@ */ #include "UPCAReader.h" -#include +#include 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 row, } Ref UPCAReader::maybeReturnResult(Ref result) { - if (result.empty()) { - return result; - } const std::string& text = (result->getText())->getText(); if (text[0] == '0') { Ref resultString(new String(text.substr(1))); Ref res(new Result(resultString, result->getRawBytes(), result->getResultPoints(), BarcodeFormat::UPC_A)); return res; + } else { + throw FormatException(); } - return Ref(); } zxing::BarcodeFormat UPCAReader::getBarcodeFormat(){