Skip to content

Commit

Permalink
Fix underflow in search functions when input is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mqudsi committed Aug 1, 2021
1 parent e9371f9 commit e2d5a8f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,10 @@ fn reverse_file(path: &str, force_flush: bool) -> std::io::Result<()> {
use_avx2 = true;
}
}
if use_avx2 {
if bytes.len() == 0 {
// Do nothing. This avoids an underflow in the search functions which expect there to
// be at least one byte.
} else if use_avx2 {
unsafe {
search256(bytes, &mut output)?;
}
Expand Down

0 comments on commit e2d5a8f

Please sign in to comment.