Fix deleteEnv null-pointer bug.

This commit is contained in:
Sage Vaillancourt 2021-12-15 14:25:47 -05:00 committed by Sage Vaillancourt
parent c0ad4481bd
commit d73247a471
1 changed files with 12 additions and 10 deletions

View File

@ -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 {