Skip to content

Commit e183799

Browse files
committed
Propagate error if retrieving encoded length fails instead of panic
Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
1 parent fe210c2 commit e183799

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/codec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ where
7575
fn encode(&mut self, item: Output, dst: &mut BytesMut) -> Result<(), Self::Error> {
7676
let mut bytes = Vec::new();
7777

78-
let len = item.encoded_len().unwrap() as u32;
78+
let len = item.encoded_len().map_err(ProtoError::SshEncoding)? as u32;
7979
len.encode(&mut bytes).map_err(ProtoError::SshEncoding)?;
8080

8181
item.encode(&mut bytes).map_err(ProtoError::SshEncoding)?;

0 commit comments

Comments
 (0)