Skip to content

Commit 06cff63

Browse files
author
Andrey Sidorov
committed
don't do Buffer.write('', offset) as this might cause OOB error if offset is at the end of buffer (even if the string is empty)
1 parent 38f334a commit 06cff63

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/packets/packet.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,10 @@ Packet.prototype.writeString = function (s) {
731731
return;
732732
}
733733

734+
if (s.length === 0) {
735+
return;
736+
}
737+
734738
var bytes = Buffer.byteLength(s, 'utf8');
735739
this.buffer.write(s, this.offset, bytes, 'utf8');
736740
this.offset += bytes;

0 commit comments

Comments
 (0)