Leak fixes (#79)

* preproc/nasm: Close the input file; addressed a few memory leaks.

* yasm.c: delete include paths before we exit

* cv-dbgfmt.c: Free cv_filename::filename too.
This commit is contained in:
bird2tori 2017-09-24 00:08:58 +02:00 committed by Peter Johnson
parent 91d628ac60
commit 4808260d62
4 changed files with 11 additions and 0 deletions

View file

@ -580,6 +580,7 @@ do_assemble(void)
yasm_linemap_destroy(linemap);
yasm_errwarns_destroy(errwarns);
cleanup(object);
yasm_delete_include_paths();
return EXIT_SUCCESS;
}

View file

@ -71,6 +71,8 @@ cv_dbgfmt_destroy(/*@only@*/ yasm_dbgfmt *dbgfmt)
for (i=0; i<dbgfmt_cv->filenames_size; i++) {
if (dbgfmt_cv->filenames[i].pathname)
yasm_xfree(dbgfmt_cv->filenames[i].pathname);
if (dbgfmt_cv->filenames[i].filename)
yasm_xfree(dbgfmt_cv->filenames[i].filename);
}
yasm_xfree(dbgfmt_cv->filenames);
yasm_xfree(dbgfmt);

View file

@ -2313,6 +2313,9 @@ expand_macros_in_string(char **p)
Token *line = tokenise(*p);
line = expand_smacro(line);
*p = detoken(line, FALSE);
do
line = delete_Token(line);
while (line);
}
/**
@ -2732,6 +2735,7 @@ do_directive(Token * tline)
inc->next = istk;
inc->conds = NULL;
inc->fp = inc_fopen(p, &newname);
nasm_free(p);
inc->fname = nasm_src_set_fname(newname);
inc->lineno = nasm_src_set_linnum(0);
inc->lineinc = 1;
@ -5051,6 +5055,7 @@ pp_getline(void)
}
istk = i->next;
list->downlevel(LIST_INCLUDE);
nasm_free(i->fname);
nasm_free(i);
if (!istk)
return NULL;

View file

@ -173,9 +173,12 @@ nasm_preproc_destroy(yasm_preproc *preproc)
yasm_xfree(preproc_nasm->line);
if (preproc_nasm->file_name)
yasm_xfree(preproc_nasm->file_name);
if (preproc_nasm->in)
fclose(preproc_nasm->in);
yasm_xfree(preproc);
if (preproc_deps)
yasm_xfree(preproc_deps);
yasm_xfree(nasm_src_set_fname(NULL));
}
static char *