Commit 6559287b authored by Seungha Yang's avatar Seungha Yang 🐑

cdg: Fix assertion failure while typefinding with too short file

thread '<unnamed>' panicked at 'assertion failed: step != 0', ...

Don't iterate with zero step size.
parent 5cba2b00
Pipeline #210698 failed with stages
in 16 minutes and 19 seconds
......@@ -60,6 +60,11 @@ fn compute_probability(typefind: &mut TypeFind) -> TypeFindProbability {
.unwrap_or(TYPEFIND_SEARCH_WINDOW as u64 * NB_WINDOWS);
let step = len / NB_WINDOWS;
// Too short file
if step == 0 {
return TypeFindProbability::None;
}
for offset in (0..len).step_by(step as usize) {
let proba = match cdg_packets_ratio(typefind, offset as i64, TYPEFIND_SEARCH_WINDOW) {
0..=5 => TypeFindProbability::None,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment