From 94a32f28f6c368645c78428c99337e145309d072 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Sat, 17 Jul 2021 20:55:06 -0400 Subject: [PATCH] fix memory leaks --- src/builtins.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/builtins.c b/src/builtins.c index 8aac90b..8b7ed9b 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -218,6 +218,10 @@ void echo(StringArray *args) { } fprintf(stdout, "%s", value); } + if (variable != NULL) { + free(variable); + variable = NULL; + } } else { if (i != 1) { @@ -236,4 +240,5 @@ void echo(StringArray *args) { } fprintf(stderr, "The variable %s doesn't exist!\n", no_variables->array[i]); } + free_string_array(no_variables); }