Alias based command implementations are not checked for variable leaks

This commit is contained in:
sagie gur ari 2020-01-25 16:41:20 +00:00
parent 13dd8b9d91
commit c3570c1377
2 changed files with 17 additions and 3 deletions

View file

@ -2,6 +2,7 @@
### v0.1.9
* Alias based command implementations are not checked for variable leaks.
* New get_home_dir command.
* New array_join command.
* The read_properties command now support **--prefix** flag.

View file

@ -90,6 +90,8 @@ impl Command for AliasCommand {
if arguments.len() < self.arguments_amount {
CommandResult::Error("Invalid arguments provided.".to_string())
} else {
let start_count = variables.len();
// define script arguments
let mut handle_option = None;
if !arguments.is_empty() {
@ -198,9 +200,20 @@ impl Command for AliasCommand {
}
clear(&self.scope_name, variables);
match flow_result {
Some(result) => result,
None => CommandResult::Continue(flow_output),
let end_count = variables.len();
if start_count != end_count {
CommandResult::Crash(
format!(
"Memory leak detected, delta variables count: {}",
end_count - start_count
)
.to_string(),
)
} else {
match flow_result {
Some(result) => result,
None => CommandResult::Continue(flow_output),
}
}
}
}