diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 612409a..cf7cd64 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -345,6 +345,7 @@ testable int getNumRawDataModules(int ver) { if (ver >= 7) result -= 36; } + assert(208 <= result && result <= 29648); return result; } diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index 4c8bdfc..a6e2568 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -531,6 +531,8 @@ int QrCode::getNumRawDataModules(int ver) { if (ver >= 7) result -= 36; } + if (!(208 <= result && result <= 29648)) + throw std::logic_error("Assertion error"); return result; } diff --git a/java/src/main/java/io/nayuki/qrcodegen/QrCode.java b/java/src/main/java/io/nayuki/qrcodegen/QrCode.java index f7d8ab7..68c4f99 100644 --- a/java/src/main/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/src/main/java/io/nayuki/qrcodegen/QrCode.java @@ -718,6 +718,7 @@ public final class QrCode { if (ver >= 7) result -= 6 * 3 * 2; // Subtract version information } + assert 208 <= result && result <= 29648; return result; } diff --git a/python/qrcodegen.py b/python/qrcodegen.py index 6ada1aa..93c0e85 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -550,6 +550,7 @@ class QrCode(object): result -= (25 * numalign - 10) * numalign - 55 if ver >= 7: result -= 36 + assert 208 <= result <= 29648 return result diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 1c38e41..258761a 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -753,6 +753,7 @@ impl QrCode { result -= 36; } } + assert!(208 <= result && result <= 29648); result } diff --git a/typescript-javascript/qrcodegen.ts b/typescript-javascript/qrcodegen.ts index 00e7827..9b75c06 100644 --- a/typescript-javascript/qrcodegen.ts +++ b/typescript-javascript/qrcodegen.ts @@ -619,6 +619,8 @@ namespace qrcodegen { if (ver >= 7) result -= 36; } + if (!(208 <= result && result <= 29648)) + throw "Assertion error"; return result; }