preproc.c: Don't forget to dup filename before free
authorCyrill Gorcunov <gorcunov@gmail.com>
Mon, 7 Mar 2011 08:23:08 +0000 (11:23 +0300)
committerCyrill Gorcunov <gorcunov@gmail.com>
Mon, 7 Mar 2011 08:23:08 +0000 (11:23 +0300)
src_set_fname simply gets copy of pointer (ideally
we need refcounting here) so don't pass the name
which will be freed soon but rather pass a copy.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
preproc.c

index d7a96d8..07179e1 100644 (file)
--- a/preproc.c
+++ b/preproc.c
@@ -5006,7 +5006,7 @@ static char *pp_getline(void)
                 /* only set line and file name if there's a next node */
                 if (i->next) {
                     src_set_linnum(i->lineno);
-                    nasm_free(src_set_fname(i->fname));
+                    nasm_free(src_set_fname(nasm_strdup(i->fname)));
                 }
                 istk = i->next;
                 list->downlevel(LIST_INCLUDE);