close File yyin before calling yylex_destroy
authorHomer Hsing <homer.xing@intel.com>
Thu, 6 Sep 2012 08:12:08 +0000 (16:12 +0800)
committerDamien Lespiau <damien.lespiau@intel.com>
Mon, 4 Mar 2013 15:54:30 +0000 (15:54 +0000)
This patch makes sure file handler yyin is closed.
yylex_destroy() calls yy_init_globals(), which reset yyin to 0.
Therefore if we do not close yyin before yylex_destroy(), yyin
will not be closed anymore.

assembler/src/main.c

index d2c5701..b5f06dc 100644 (file)
@@ -275,11 +275,11 @@ int main(int argc, char **argv)
 
        err = yyparse();
 
-       yylex_destroy();
-
-       if (yyin)
+       if (strcmp(argv[0], "-"))
                fclose(yyin);
 
+       yylex_destroy();
+
        if (err || errors)
                exit (1);