From 8cd6be853b61798a5fd4114292c62bb9384497bc Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Sat, 3 Aug 2019 17:45:09 -0400 Subject: Fix double free error --- node.c | 5 ++++- scope.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/node.c b/node.c index fbbfd14..586ed52 100644 --- a/node.c +++ b/node.c @@ -47,7 +47,10 @@ node *n; { node *tmp; - for(tmp = n; tmp; tmp = n = n->next) { + for(tmp = n; tmp;) { + n = tmp->next; free(tmp); + tmp = NULL; + tmp = n; } } diff --git a/scope.c b/scope.c index 11a9c5b..6706765 100644 --- a/scope.c +++ b/scope.c @@ -35,6 +35,7 @@ scope *s; } free(s); + s = NULL; } /*Copied from Compilers, Aho*/ -- cgit v1.1