diff --git a/io/bytebuffer.js b/io/bytebuffer.js index 444c9e2..71f7401 100644 --- a/io/bytebuffer.js +++ b/io/bytebuffer.js @@ -53,7 +53,7 @@ bitjs.io.ByteBuffer = class { * @param {number} numBytes The number of bytes to write the number into. */ writeNumber(num, numBytes) { - if (numBytes < 1) { + if (numBytes < 1 || !numBytes) { throw 'Trying to write into too few bytes: ' + numBytes; } if (num < 0) { diff --git a/tests/io-test.html b/tests/io-test.html index cfbbba3..a19e824 100644 --- a/tests/io-test.html +++ b/tests/io-test.html @@ -1,7 +1,7 @@
-