Check for bad dimension every time to produce more meaningful error

git-svn-id: https://zxing.googlecode.com/svn/trunk@2269 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-04-26 18:23:25 +00:00
parent 9de4dd7256
commit 8768f73604

View file

@ -50,11 +50,11 @@ public final class BitSource {
* @param numBits number of bits to read
* @return int representing the bits read. The bits will appear as the least-significant
* bits of the int
* @throws IllegalArgumentException if numBits isn't in [1,32]
* @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available
*/
public int readBits(int numBits) {
if (numBits < 1 || numBits > 32) {
throw new IllegalArgumentException();
if (numBits < 1 || numBits > 32 || numBits > available()) {
throw new IllegalArgumentException(String.valueOf(numBits));
}
int result = 0;