From 275d64928775523aff6068542267e1707a8d2bed Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 20 Mar 2024 13:35:44 +0100 Subject: [PATCH] move `header.length` check in `yamux` to original location (#1069) --- libp2p/muxers/yamux/yamux.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libp2p/muxers/yamux/yamux.nim b/libp2p/muxers/yamux/yamux.nim index 5f12a5ead..a65890d24 100644 --- a/libp2p/muxers/yamux/yamux.nim +++ b/libp2p/muxers/yamux/yamux.nim @@ -555,13 +555,13 @@ method handle*(m: Yamux) {.async: (raises: []).} = if flushed[] < 0: raise newException(YamuxError, "Peer exhausted the recvWindow after reset") + if header.length > 0: + var buffer = newSeqUninitialized[byte](header.length) + await m.connection.readExactly( + addr buffer[0], int(header.length)) do: raise newException(YamuxError, "Unknown stream ID: " & $header.streamId) - if header.length > 0: - var buffer = newSeqUninitialized[byte](header.length) - await m.connection.readExactly( - addr buffer[0], int(header.length)) continue let channel =