Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix buffer length for QR code gen. #5447

Merged
merged 1 commit into from
Apr 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion js/src/ui/QrCode/qrSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand Down