diff --git a/src/host/buildvm.c b/src/host/buildvm.c index ec99e501..6c505cf3 100644 --- a/src/host/buildvm.c +++ b/src/host/buildvm.c @@ -10,7 +10,7 @@ ** _building_ LuaJIT. There's no point in distributing or installing it. ** Only the object code generated by this tool is linked into LuaJIT. ** -** Caveat: some memory is not free'd, error handling is lazy. +** Caveat: error handling is lazy. ** It's a one-shot tool -- any effort fixing this would be wasted. */ @@ -524,6 +524,20 @@ int main(int argc, char **argv) } fclose(ctx->fp); + // cleanup + free(ctx->code); + free(ctx->glob); + for(int i=0; i<=ctx->nsym; i++) { + free((void*)ctx->sym[i].name); + } + free(ctx->sym); + for(int i=0; inrelocsym; i++) { + free((void*)ctx->relocsym[i]); + } + free(ctx->relocsym); + free(ctx->bc_ofs); + free((void*)ctx->beginsym); + return 0; }