]> granicus.if.org Git - yasm/commitdiff
Leak fixes (#79)
authorbird2tori <bird-github@anduin.net>
Sat, 23 Sep 2017 22:08:58 +0000 (00:08 +0200)
committerPeter Johnson <johnson.peter@gmail.com>
Sat, 23 Sep 2017 22:08:58 +0000 (15:08 -0700)
* 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.

frontends/yasm/yasm.c
modules/dbgfmts/codeview/cv-dbgfmt.c
modules/preprocs/nasm/nasm-pp.c
modules/preprocs/nasm/nasm-preproc.c

index 75d96755cb70e2da10a1dc845e27c0ad6ee24530..bc6f379adc847faf0a6a685400c309aba6cbbc0d 100644 (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;
 }
 
index 9b06fe3495b79db216bac78c25724ccc4e4de08b..e39a725f668d9e12bfed4de2d2e9cc77769a52dd 100644 (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);
index 5ea650e30b30d8db1359ee10c9d06f7169040d8b..32ebcd00fa7b05b8614317c11fd8c19c498bf170 100644 (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;
index 0b364b1f06efe2468e89403c8c9584e5f5f9e5ff..96d66dbcf2b615b266c73c2547ba74b14cf3fecf 100644 (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 *