From d73247a4716dbf2d949943d395b5816884d719a9 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 15 Dec 2021 14:25:47 -0500 Subject: [PATCH] Fix deleteEnv null-pointer bug. --- src/env.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/env.c b/src/env.c index d8d126b..5b9f93a 100644 --- a/src/env.c +++ b/src/env.c @@ -180,17 +180,19 @@ void addFunc(const char *name, Object (*func)(Object, Object, struct Environment void deleteEnv(struct Environment *e) { - int i = 0; - while(e->strings[i]) { - free(e->strings[i]); - cleanObject(&e->objects[i]); - i++; - } - free(e->strings); - e->strings = NULL; + if (e->strings) { + int i = 0; + while(e->strings[i]) { + free(e->strings[i]); + cleanObject(&e->objects[i]); + i++; + } + free(e->strings); + e->strings = NULL; - free(e->objects); - e->objects = NULL; + free(e->objects); + e->objects = NULL; + } } struct symFunc {