mirror of
https://github.com/status-im/QR-Code-generator.git
synced 2025-02-24 10:28:20 +00:00
Added length check and tweaked a cast in C++ code.
This commit is contained in:
parent
3305d230c1
commit
5b060413b6
@ -57,10 +57,12 @@ const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0);
|
|||||||
|
|
||||||
|
|
||||||
QrSegment QrSegment::makeBytes(const vector<uint8_t> &data) {
|
QrSegment QrSegment::makeBytes(const vector<uint8_t> &data) {
|
||||||
|
if (data.size() > INT_MAX)
|
||||||
|
throw "Data too long";
|
||||||
BitBuffer bb;
|
BitBuffer bb;
|
||||||
for (uint8_t b : data)
|
for (uint8_t b : data)
|
||||||
bb.appendBits(b, 8);
|
bb.appendBits(b, 8);
|
||||||
return QrSegment(Mode::BYTE, (int)data.size(), std::move(bb));
|
return QrSegment(Mode::BYTE, static_cast<int>(data.size()), std::move(bb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user