Skip to content

Commit

Permalink
fix: issue introduced in previous commit
Browse files Browse the repository at this point in the history
The issue was calling `len` on an iterator that was already consumed.
  • Loading branch information
plusvic committed Sep 22, 2023
1 parent ccf6d52 commit e26dfb8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions yara-x-cli/src/commands/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,30 +149,30 @@ pub fn exec_scan(args: &ArgMatches) -> anyhow::Result<()> {

let scan_results = scan_results?;

let num_matching_rules = if negate {
if negate {
let mut matching_rules = scan_results.non_matching_rules();
if matching_rules.len() > 0 {
state.num_matching_files.fetch_add(1, Ordering::Relaxed);
}
print_matching_rules(
args,
&file_path,
&mut matching_rules,
output,
);
matching_rules.len()
} else {
let mut matching_rules = scan_results.matching_rules();
if matching_rules.len() > 0 {
state.num_matching_files.fetch_add(1, Ordering::Relaxed);
}
print_matching_rules(
args,
&file_path,
&mut matching_rules,
output,
);
matching_rules.len()
};

if num_matching_rules > 0 {
state.num_matching_files.fetch_add(1, Ordering::Relaxed);
}

state.num_scanned_files.fetch_add(1, Ordering::Relaxed);

Ok(())
Expand Down

0 comments on commit e26dfb8

Please sign in to comment.