Skip to content

Commit

Permalink
fix: fix incorrect handling of map length while parsing map frames
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Saini committed Nov 5, 2022
1 parent 408591b commit c130213
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/frame.rs
Expand Up @@ -145,9 +145,6 @@ fn parse_null(line: &[u8]) -> Result<Frame, ParseFrameError> {

fn parse_map(buf: &mut Cursor<&[u8]>, line: &[u8]) -> Result<Frame, ParseFrameError> {
let len = atoi::<usize>(line).ok_or(ParseFrameError::InvalidFormat)?;
if len % 2 != 0 {
return Err(ParseFrameError::InvalidFormat);
}
let mut map = Vec::with_capacity(2 * len);
for _ in 0..len {
let key = parse(buf)?;
Expand Down Expand Up @@ -533,12 +530,6 @@ mod tests {
assert_eq!(parse(&mut buf), Err(ParseFrameError::InvalidFormat))
}

#[test]
fn parse_given_map_with_odd_length_return_invalid_format_error() {
let mut buf = get_cursor_from_bytes(b"#1\r\n$3\r\nfoo\r\n");
assert_eq!(parse(&mut buf), Err(ParseFrameError::InvalidFormat))
}

#[test]
fn parse_given_incomplete_map_return_incomplete_error() {
let mut buf = get_cursor_from_bytes(b"#2\r\n$3\r\nfoo\r\n");
Expand Down

0 comments on commit c130213

Please sign in to comment.