Do not copy more bytes than were read

This commit is contained in:
Wichert Akkerman 2019-10-21 10:05:43 +02:00 committed by Mickaël Rémond
parent ffadd331dd
commit 38bdcaec36

View file

@ -100,7 +100,7 @@ func (t WebsocketTransport) startReader() {
if n > 0 { if n > 0 {
// We need to make a copy, otherwise we will overwrite the slice content // We need to make a copy, otherwise we will overwrite the slice content
// on the next iteration of the for loop. // on the next iteration of the for loop.
tmp := make([]byte, len(buffer)) tmp := make([]byte, n)
copy(tmp, buffer) copy(tmp, buffer)
t.queue <- tmp t.queue <- tmp
} }