diff options
author | Seungha Yang <seungha@centricular.com> | 2020-10-04 14:44:44 +0300 |
---|---|---|
committer | Seungha Yang <seungha@centricular.com> | 2020-10-04 14:44:44 +0300 |
commit | 6559287bea7fd8a70a4e0d70f983570318029cf9 (patch) | |
tree | 29e35fe99693d3da4734fd09541c1d2ca3bad5fd /video/cdg | |
parent | 5cba2b002b50d61eed4ba977081ad28be0b58ddb (diff) |
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.
Diffstat (limited to 'video/cdg')
-rw-r--r-- | video/cdg/src/lib.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/video/cdg/src/lib.rs b/video/cdg/src/lib.rs index ea547175c..4083adc7b 100644 --- a/video/cdg/src/lib.rs +++ b/video/cdg/src/lib.rs @@ -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, |