fix(main): memeory leaks from vars on error_input_processing
This commit is contained in:
parent
71fadb1b4a
commit
6be3dde607
1 changed files with 13 additions and 5 deletions
18
src/main.c
18
src/main.c
|
|
@ -18,6 +18,15 @@
|
||||||
|
|
||||||
// === Functions
|
// === 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,
|
static int main_loop(struct lexer_context *ctx, struct args_options *options,
|
||||||
struct hash_map *vars)
|
struct hash_map *vars)
|
||||||
{
|
{
|
||||||
|
|
@ -49,7 +58,7 @@ static int main_loop(struct lexer_context *ctx, struct args_options *options,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command_ast == NULL)
|
if (command_ast == NULL)
|
||||||
return ERR_INPUT_PROCESSING;
|
return err_input(&vars);
|
||||||
|
|
||||||
ast_free(&command_ast);
|
ast_free(&command_ast);
|
||||||
|
|
||||||
|
|
@ -71,7 +80,7 @@ int main(int argc, char **argv)
|
||||||
if (return_code != 0)
|
if (return_code != 0)
|
||||||
{
|
{
|
||||||
print_usage(stderr, argv[0]);
|
print_usage(stderr, argv[0]);
|
||||||
return ERR_INPUT_PROCESSING;
|
return err_input(&vars);
|
||||||
}
|
}
|
||||||
// args_print(&options);
|
// args_print(&options);
|
||||||
|
|
||||||
|
|
@ -86,7 +95,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error: Failed to configure IO Backend from arguments\n");
|
"Error: Failed to configure IO Backend from arguments\n");
|
||||||
return ERR_INPUT_PROCESSING;
|
return err_input(&vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init IO Backend (with the context struct)
|
// Init IO Backend (with the context struct)
|
||||||
|
|
@ -96,10 +105,9 @@ int main(int argc, char **argv)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error: IO Backend initialization failed with code %d\n",
|
"Error: IO Backend initialization failed with code %d\n",
|
||||||
return_code);
|
return_code);
|
||||||
return ERR_INPUT_PROCESSING;
|
return err_input(&vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// init lexer context
|
// init lexer context
|
||||||
struct lexer_context ctx = { 0 };
|
struct lexer_context ctx = { 0 };
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue