]> Chaos Git - misc/ysh.git/commitdiff
shell: clean up memory
authorJon Feldman <chaos.kagami@gmail.com>
Wed, 26 Jul 2017 13:49:20 +0000 (09:49 -0400)
committerJon Feldman <chaos.kagami@gmail.com>
Wed, 26 Jul 2017 13:49:20 +0000 (09:49 -0400)
gsh_main.c

index 58e0fe6a130e317f7443791e44717900b358ec9a..715cbe9561661c4f18201c303d875bd2c8e923d4 100644 (file)
@@ -484,6 +484,8 @@ int main(int argc, char **argv) {
         ast_t *toks = parse(run_str);
         toks        = resolve(toks);
         execute(toks, NULL);
+        free(toks->ptr);
+        free(toks);
     } else {
         while (!shell_do_exit) {
             // Read a command in.
@@ -491,6 +493,8 @@ int main(int argc, char **argv) {
             ast_t *toks  = parse(input);
             toks         = resolve(toks);
             execute(toks, NULL);
+            free(toks->ptr);
+            free(toks);
             // FIXME: free the damn toks memory, this requires traversing to the bottom tho
             free(input);
         }