fixed exception with invalid buffer length

This commit is contained in:
Andris Reinman 2020-01-11 15:04:26 +02:00
parent 64ccb33ee5
commit df1b73083a
No known key found for this signature in database
GPG key ID: 5388A30A31834D83

View file

@ -63,8 +63,10 @@ class LengthLimiter extends Transform {
_flush(done) { _flush(done) {
if (!this.finished) { if (!this.finished) {
// add padding if incoming stream stopped too early // add padding if incoming stream stopped too early
if (this.expectedLength > this.byteCounter) {
let buf = Buffer.from(this.padding.repeat(this.expectedLength - this.byteCounter)); let buf = Buffer.from(this.padding.repeat(this.expectedLength - this.byteCounter));
this.push(buf); this.push(buf);
}
this.finished = true; this.finished = true;
} }
done(); done();