fix(main): memeory leaks from vars on error_input_processing

This commit is contained in:
matteo 2026-01-24 13:20:29 +01:00
parent 71fadb1b4a
commit 6be3dde607

View file

@ -18,6 +18,15 @@
// === Functions
/* @brief: frees the hash map.
* @return: always ERR_INPUT_PROCESSING.
*/
static int err_input(struct hash_map **vars)
{
hash_map_free(vars);
return ERR_INPUT_PROCESSING;
}
static int main_loop(struct lexer_context *ctx, struct args_options *options,
struct hash_map *vars)
{
@ -49,7 +58,7 @@ static int main_loop(struct lexer_context *ctx, struct args_options *options,
}
if (command_ast == NULL)
return ERR_INPUT_PROCESSING;
return err_input(&vars);
ast_free(&command_ast);
@ -71,7 +80,7 @@ int main(int argc, char **argv)
if (return_code != 0)
{
print_usage(stderr, argv[0]);
return ERR_INPUT_PROCESSING;
return err_input(&vars);
}
// args_print(&options);
@ -86,7 +95,7 @@ int main(int argc, char **argv)
{
fprintf(stderr,
"Error: Failed to configure IO Backend from arguments\n");
return ERR_INPUT_PROCESSING;
return err_input(&vars);
}
// Init IO Backend (with the context struct)
@ -96,10 +105,9 @@ int main(int argc, char **argv)
fprintf(stderr,
"Error: IO Backend initialization failed with code %d\n",
return_code);
return ERR_INPUT_PROCESSING;
return err_input(&vars);
}
// init lexer context
struct lexer_context ctx = { 0 };