Fix memory leaks in compiler
diff --git a/src/lisp/compiler.dasc b/src/lisp/compiler.dasc
index a0b0236..122538c 100644
--- a/src/lisp/compiler.dasc
+++ b/src/lisp/compiler.dasc
@@ -105,6 +105,8 @@
{
next = f->prev;
// We're not gonna bother munmap()ing the function
+ if (f->args)
+ free(f->args);
free(f);
}
@@ -207,10 +209,15 @@
if (local_out)
*local_out = local;
+ else
+ del_local(&local);
if (args_out)
*args_out = ar;
+ if (!local_out && !args_out)
+ free(ar);
+
*state = d;
OKAY();
@@ -408,6 +415,8 @@
snprintf(full_path, 512, "%s/%s", dirname(relative_to), new_path);
+ free(relative_to);
+
if (load(env, full_path))
return t;
else
@@ -775,7 +784,7 @@
{
// Compile the function with this as the parent scope
struct local new_local;
- int nargs_out;
+ struct args *nargs_out;
dasm_State *d;
TRY(compile_function(
args, NS_ANONYMOUS, env, &new_local, local, &nargs_out,
@@ -1251,6 +1260,8 @@
add_variable(local, V_ARGUMENT, (char *)(name ^ SYMBOL_TAG),
args->num_required + args->num_optional - 1);
+
+ dasm_free(&d);
}
}