Fix buffer length for QR code gen. (#5447)

This commit is contained in:
Gav Wood 2017-04-12 13:20:22 +02:00 committed by GitHub
parent a0d83537e5
commit 1b36a381e8

View File

@ -69,7 +69,9 @@ const QR_SIZES = [
export function calculateType (lengthBytes, errorLevel = 'M') {
let type = 5;
while (type < 40 && lengthBytes > QR_SIZES[errorLevel][type - 1]) {
// subtract 3 from the capacities, since we need 2 bits for the mode and a
// bunch more for the length.
while (type < 40 && lengthBytes > QR_SIZES[errorLevel][type - 1] - 3) {
type++;
}