Skip to content

Commit 8209d9e

Browse files
committed
sh: handle count too large in vi mode
1 parent c440f81 commit 8209d9e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sh/src/cli/vi/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ impl Command {
129129
return Err(CommandParseError::IncompleteCommand);
130130
}
131131
let count = if last_digit != 0 && bytes[last_digit] != b'0' {
132-
// TODO: handle count too big
133-
let count = std::str::from_utf8(&bytes[..last_digit])
132+
match std::str::from_utf8(&bytes[..last_digit])
134133
.unwrap()
135134
.parse::<usize>()
136-
.unwrap();
137-
Some(count - 1)
135+
{
136+
Ok(count) => Some(count - 1),
137+
Err(_) => return Err(CommandParseError::InvalidCommand),
138+
}
138139
} else {
139140
None
140141
};

0 commit comments

Comments
 (0)