diff --git a/cpp/core/src/zxing/common/CharacterSetECI.cpp b/cpp/core/src/zxing/common/CharacterSetECI.cpp index 80603c6cb..8386208b5 100644 --- a/cpp/core/src/zxing/common/CharacterSetECI.cpp +++ b/cpp/core/src/zxing/common/CharacterSetECI.cpp @@ -16,8 +16,8 @@ */ #include -#include #include +#include using std::string; @@ -94,9 +94,7 @@ void CharacterSetECI::addCharacterSet(int const* values, char const* const* name CharacterSetECI* CharacterSetECI::getCharacterSetECIByValue(int value) { if (value < 0 || value >= 900) { - std::ostringstream oss; - oss << "Bad ECI value: " << value; - throw IllegalArgumentException(oss.str().c_str()); + throw FormatException(); } return VALUE_TO_ECI[value]; } diff --git a/cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp b/cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp index 1a208e61d..83ef51239 100644 --- a/cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp +++ b/cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp @@ -275,6 +275,9 @@ void DecodedBitStreamParser::decodeAlphanumericSegment(Ref bits_, ostringstream bytes; // Read two characters at a time while (count > 1) { + if (bits.available() < 11) { + throw FormatException(); + } int nextTwoCharsBits = bits.readBits(11); bytes << toAlphaNumericChar(nextTwoCharsBits / 45); bytes << toAlphaNumericChar(nextTwoCharsBits % 45); @@ -324,7 +327,7 @@ namespace { int secondThirdBytes = bits.readBits(16); return ((firstByte & 0x1F) << 16) | secondThirdBytes; } - throw IllegalArgumentException("Bad ECI bits starting with byte " + firstByte); + throw FormatException(); } }