diff --git a/java/io/nayuki/qrcodegen/BitBuffer.java b/java/io/nayuki/qrcodegen/BitBuffer.java index 4d8c5d7..722a07f 100644 --- a/java/io/nayuki/qrcodegen/BitBuffer.java +++ b/java/io/nayuki/qrcodegen/BitBuffer.java @@ -97,6 +97,7 @@ public final class BitBuffer implements Cloneable { * to this sequence. Requires 0 ≤ val < 2len. * @param val the value to append * @param len the number of low bits in the value to take + * @throws IllegalArgumentException if the value or number of bits is out of range * @throws IllegalStateException if appending the data * would make bitLength exceed Integer.MAX_VALUE */ diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 3f42530..bb57352 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1067,7 +1067,7 @@ impl BitBuffer { // Appends the given number of low bits of the given value // to this sequence. Requires 0 <= len <= 31 and 0 <= val < 2^len. pub fn append_bits(&mut self, val: u32, len: u8) { - assert!(len < 32 && (val >> len) == 0 || len == 32, "Value out of range"); + assert!(len <= 31 && (val >> len) == 0, "Value out of range"); self.0.extend((0 .. len as i32).rev().map(|i| get_bit(val, i))); // Append bit by bit } }