diff --git a/lib/bcoin/writer.js b/lib/bcoin/writer.js index bec886bd..025f1237 100644 --- a/lib/bcoin/writer.js +++ b/lib/bcoin/writer.js @@ -103,7 +103,7 @@ BufferWriter.prototype.render = function render(keep) { off += utils.checksum(data.slice(0, off)).copy(data, off); break; case FILL: - item[1].fill(item[1], off, off + item[2]); + data.fill(item[1], off, off + item[2]); off += item[2]; break; default: @@ -438,6 +438,10 @@ BufferWriter.prototype.writeChecksum = function writeChecksum() { BufferWriter.prototype.fill = function fill(value, size) { assert(size >= 0); + + if (size === 0) + return; + this.written += size; this.data.push([FILL, value, size]); };