preproc: inc_fopen -- set sl->next early
authorCyrill Gorcunov <gorcunov@gmail.com>
Thu, 11 Nov 2010 08:32:16 +0000 (11:32 +0300)
committerCyrill Gorcunov <gorcunov@gmail.com>
Thu, 11 Nov 2010 19:44:18 +0000 (22:44 +0300)
It's safer to init it early and be sure we not
miss anything after.

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

index df59cf057caaa4e56a18604e6b5e54138ba0565b..7c85e5aa0e24983cc90fe448b34984d138d6647f 100644 (file)
--- a/preproc.c
+++ b/preproc.c
@@ -1655,11 +1655,11 @@ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail,
 
     while (1) {
         sl = nasm_malloc(prefix_len+len+1+sizeof sl->next);
+        sl->next = NULL;
         memcpy(sl->str, prefix, prefix_len);
         memcpy(sl->str+prefix_len, file, len+1);
         fp = fopen(sl->str, "r");
         if (fp && dhead && !in_list(*dhead, sl->str)) {
-            sl->next = NULL;
             **dtail = sl;
             *dtail = &sl->next;
         } else {