From: srowen Date: Thu, 12 Aug 2010 20:54:54 +0000 (+0000) Subject: Issue 509 X-Git-Url: http://git.rot13.org/?p=zxing.git;a=commitdiff_plain;h=71e43f894a1ed8dfd40536d2268c2744332daebb Issue 509 git-svn-id: http://zxing.googlecode.com/svn/trunk@1525 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- diff --git a/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp b/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp index 04cd06bc..3e3a5ffa 100644 --- a/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp +++ b/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp @@ -84,7 +84,7 @@ Version *BitMatrixParser::readVersion() { return parsedVersion_; } - size_t dimension = bitMatrix_->getDimension(); + int dimension = bitMatrix_->getDimension(); int provisionalVersion = (dimension - 17) >> 2; if (provisionalVersion <= 6) { @@ -101,7 +101,7 @@ Version *BitMatrixParser::readVersion() { } parsedVersion_ = Version::decodeVersionInformation(versionBits); - if (parsedVersion_ != 0) { + if (parsedVersion_ != 0 && parsedVersion_->getDimensionForVersion() == dimension) { return parsedVersion_; } @@ -115,7 +115,7 @@ Version *BitMatrixParser::readVersion() { } parsedVersion_ = Version::decodeVersionInformation(versionBits); - if (parsedVersion_ != 0) { + if (parsedVersion_ != 0 && parsedVersion_->getDimensionForVersion() == dimension) { return parsedVersion_; } throw ReaderException("Could not decode version"); diff --git a/cpp/core/src/zxing/qrcode/detector/Detector.cpp b/cpp/core/src/zxing/qrcode/detector/Detector.cpp index bba077f9..4e40b723 100644 --- a/cpp/core/src/zxing/qrcode/detector/Detector.cpp +++ b/cpp/core/src/zxing/qrcode/detector/Detector.cpp @@ -53,6 +53,9 @@ Ref Detector::detect(DecodeHints const& hints) { Ref bottomLeft(info->getBottomLeft()); float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft); + if (moduleSize < 1.0f) { + throw zxing::ReaderException("bad module size"); + } int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize); Version *provisionalVersion = Version::getProvisionalVersionForDimension(dimension); int modulesBetweenFPCenters = provisionalVersion->getDimensionForVersion() - 7;