Fix fclose bug on error.
authorVictor van den Elzen <victor.vde@gmail.com>
Wed, 4 Jun 2008 13:24:20 +0000 (15:24 +0200)
committerVictor van den Elzen <victor.vde@gmail.com>
Wed, 16 Jul 2008 10:20:23 +0000 (12:20 +0200)
Contrary to the comments, the fclose is needed.
Failure to close the file caused remove to fail on Windows.

nasm.c

diff --git a/nasm.c b/nasm.c
index e21d08918ad80d1e7d220f6e4eb8cdc5bcc9bc09..66c69bf8c81ae25bc2c02d57884223c225a9941f 100644 (file)
--- a/nasm.c
+++ b/nasm.c
@@ -443,11 +443,12 @@ int main(int argc, char **argv)
                 cleanup_labels();
             } else {
                 /*
-                 * We had an fclose on the output file here, but we
-                 * actually do that in all the object file drivers as well,
-                 * so we're leaving out the one here.
-                 *     fclose (ofile);
+                 * Despite earlier comments, we need this fclose.
+                 * The object output drivers only fclose on cleanup,
+                 * and we just skipped that.
                  */
+                fclose (ofile);
+
                 remove(outname);
                 if (listname[0])
                     remove(listname);