fix(execution): var update leak
This commit is contained in:
parent
e32715ce13
commit
c448776268
3 changed files with 1 additions and 15 deletions
|
|
@ -40,8 +40,6 @@ int execution(struct ast *ast, struct hash_map *vars)
|
||||||
return exec_ast_list(ast_get_list(ast), vars);
|
return exec_ast_list(ast_get_list(ast), vars);
|
||||||
case AST_AND_OR:
|
case AST_AND_OR:
|
||||||
return exec_ast_and_or(ast_get_and_or(ast), vars);
|
return exec_ast_and_or(ast_get_and_or(ast), vars);
|
||||||
case AST_ASSIGNMENT:
|
|
||||||
return exec_ast_assignment(ast_get_assignment(ast), vars);
|
|
||||||
default:
|
default:
|
||||||
return 127;
|
return 127;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,10 +137,7 @@ static int exec_assignment(struct list *assignment_list, struct hash_map *vars)
|
||||||
struct ast_assignment *assignment =
|
struct ast_assignment *assignment =
|
||||||
ast_get_assignment(assignment_list->data);
|
ast_get_assignment(assignment_list->data);
|
||||||
|
|
||||||
char *key = strdup(assignment->name);
|
set_var_copy(vars, assignment->name, assignment->value);
|
||||||
char *value = strdup(assignment->value);
|
|
||||||
hash_map_insert(vars, key, value, NULL);
|
|
||||||
|
|
||||||
assignment_list = assignment_list->next;
|
assignment_list = assignment_list->next;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -148,7 +145,6 @@ static int exec_assignment(struct list *assignment_list, struct hash_map *vars)
|
||||||
|
|
||||||
int exec_ast_command(struct ast_command *command, struct hash_map *vars)
|
int exec_ast_command(struct ast_command *command, struct hash_map *vars)
|
||||||
{
|
{
|
||||||
(void)vars;
|
|
||||||
exec_assignment(command->assignments, vars);
|
exec_assignment(command->assignments, vars);
|
||||||
set_all_redir(command->redirections);
|
set_all_redir(command->redirections);
|
||||||
|
|
||||||
|
|
@ -203,13 +199,6 @@ int exec_ast_command(struct ast_command *command, struct hash_map *vars)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int exec_ast_assignment(struct ast_assignment *assign, struct hash_map *vars)
|
|
||||||
{
|
|
||||||
set_var_copy(vars, assign->name, assign->value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int exec_ast_if(struct ast_if *if_node, struct hash_map *vars)
|
int exec_ast_if(struct ast_if *if_node, struct hash_map *vars)
|
||||||
{
|
{
|
||||||
int cond = execution(if_node->condition, vars);
|
int cond = execution(if_node->condition, vars);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ int exec_ast_command(struct ast_command *command, struct hash_map *vars);
|
||||||
int exec_ast_if(struct ast_if *if_node, struct hash_map *vars);
|
int exec_ast_if(struct ast_if *if_node, struct hash_map *vars);
|
||||||
int exec_ast_list(struct ast_list *list_node, struct hash_map *vars);
|
int exec_ast_list(struct ast_list *list_node, struct hash_map *vars);
|
||||||
int exec_ast_and_or(struct ast_and_or *ao_node, struct hash_map *vars);
|
int exec_ast_and_or(struct ast_and_or *ao_node, struct hash_map *vars);
|
||||||
int exec_ast_assignment(struct ast_assignment *assign, struct hash_map *vars);
|
|
||||||
|
|
||||||
void unset_all_redir(struct list *redir_list);
|
void unset_all_redir(struct list *redir_list);
|
||||||
#endif // EXECUTION_HELPERS_H
|
#endif // EXECUTION_HELPERS_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue