This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[fortran,patch] PR40195, we forget to close a module file
- From: FX <fxcoudert at gmail dot com>
- To: Fortran List <fortran at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 May 2009 23:11:45 +0200
- Subject: [fortran,patch] PR40195, we forget to close a module file
Hi all
The patch below fixes PR 40195: when we open a .mod file to check its
content, there is one codepath where we forget to close it. On
Windows, this prevents the file from being unlinked later on (which
aborts the compilation). The patch simply adds a call to fclose(), and
also slightly adjusts the comments.
Built and tested on i386-pc-mingw32, currently regtesting on x86_64-
linux. OK to commit?
Thanks,
FX
Index: module.c
===================================================================
--- module.c (revision 147744)
+++ module.c (working copy)
@@ -4759,7 +4759,7 @@ read_md5_from_module_file (const char *
if ((file = fopen (filename, "r")) == NULL)
return -1;
- /* Read two lines. */
+ /* Read the first line. */
if (fgets (buf, sizeof (buf) - 1, file) == NULL)
{
fclose (file);
@@ -4769,8 +4769,12 @@ read_md5_from_module_file (const char *
/* The file also needs to be overwritten if the version number
changed. */
n = strlen ("GFORTRAN module version '" MOD_VERSION "' created");
if (strncmp (buf, "GFORTRAN module version '" MOD_VERSION "'
created", n) !=
0)
- return -1;
+ {
+ fclose (file);
+ return -1;
+ }
+ /* Read a second line. */
if (fgets (buf, sizeof (buf) - 1, file) == NULL)
{
fclose (file);