Skip to content

Commit a717663

Browse files
committed
substream/fix: Handle empty payloads with 0-length frames
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
1 parent 276b190 commit a717663

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/substream/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,13 @@ impl Stream for Substream {
645645
}
646646

647647
this.offset = 0;
648+
// Handle empty payloads detected as 0-length frame.
649+
// The offset must be cleared to 0 to not interfere
650+
// with next framing.
651+
if size == 0 {
652+
return Poll::Ready(Some(Ok(BytesMut::new())));
653+
}
654+
648655
this.current_frame_size = Some(size);
649656
this.read_buffer = BytesMut::zeroed(size);
650657
}

0 commit comments

Comments
 (0)