diff --git a/cpp/QrSegment.cpp b/cpp/QrSegment.cpp index 4694ee4..df8763c 100644 --- a/cpp/QrSegment.cpp +++ b/cpp/QrSegment.cpp @@ -57,10 +57,12 @@ const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0); QrSegment QrSegment::makeBytes(const vector &data) { + if (data.size() > INT_MAX) + throw "Data too long"; BitBuffer bb; for (uint8_t b : data) bb.appendBits(b, 8); - return QrSegment(Mode::BYTE, (int)data.size(), std::move(bb)); + return QrSegment(Mode::BYTE, static_cast(data.size()), std::move(bb)); }