Skip to content

Commit

Permalink
fixed exception with invalid buffer length
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Jan 11, 2020
1 parent 64ccb33 commit df1b730
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions imap-core/lib/length-limiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ class LengthLimiter extends Transform {
_flush(done) {
if (!this.finished) {
// add padding if incoming stream stopped too early
let buf = Buffer.from(this.padding.repeat(this.expectedLength - this.byteCounter));
this.push(buf);
if (this.expectedLength > this.byteCounter) {
let buf = Buffer.from(this.padding.repeat(this.expectedLength - this.byteCounter));
this.push(buf);
}
this.finished = true;
}
done();
Expand Down

0 comments on commit df1b730

Please sign in to comment.