Fix buffer length calculation in ServerAdvertisement (#292)
This commit is contained in:
parent
c51b55d4c7
commit
9724ff41ed
1 changed files with 3 additions and 2 deletions
|
|
@ -51,8 +51,9 @@ class ServerAdvertisement {
|
|||
|
||||
toBuffer (version) {
|
||||
const str = this.toString(version)
|
||||
const buf = Buffer.alloc(2 + str.length)
|
||||
buf.writeUInt16BE(str.length, 0)
|
||||
const length = Buffer.byteLength(str)
|
||||
const buf = Buffer.alloc(2 + length)
|
||||
buf.writeUInt16BE(length, 0)
|
||||
buf.write(str, 2)
|
||||
return buf
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue