re PR fortran/40195 (Cannot unlink existing module file)

PR fortran/40195
	* module.c (read_md5_from_module_file): Close file before returning.

From-SVN: r147796
This commit is contained in:
Francois-Xavier Coudert 2009-05-22 12:54:23 +00:00 committed by François-Xavier Coudert
parent 6fc2aa8f75
commit 68aed7e4a6
2 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2009-05-22 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/40195
* module.c (read_md5_from_module_file): Close file before returning.
2009-05-10 Paul Thomas <pault@gcc.gnu.org>
Backport from mainline:

View File

@ -4738,7 +4738,7 @@ read_md5_from_module_file (const char * filename, unsigned char md5[16])
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);
@ -4748,8 +4748,12 @@ read_md5_from_module_file (const char * filename, unsigned char md5[16])
/* 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);