aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2015-07-15 10:00:23 +0300
committerJanne Blomqvist <jb@gcc.gnu.org>2015-07-15 10:00:23 +0300
commit231ff5dde169bd57b1dcc9bd75282eb5dc3dd180 (patch)
tree36cd0eb604a5b9a05f05b379ca53f5621e42a1e3
parent91282bad369c97042bf653935a71ae3a5444b744 (diff)
PR 66861 Fix null pointer crash on mingw.
2015-07-15 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/66861 * io/unix.c (compare_file_filename): Verify that u->filename is non-NULL before strcmp. (find_file0): Likewise. From-SVN: r225805
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/unix.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 07b36fdd194..9cf39e62b78 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2015-07-15 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/66861
+ * io/unix.c (compare_file_filename): Verify that u->filename is
+ non-NULL before strcmp.
+ (find_file0): Likewise.
+
2015-04-22 Release Manager
* GCC 5.1.0 released.
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index e5fc6e19818..a1ce9a3ffe7 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1525,7 +1525,10 @@ compare_file_filename (gfc_unit *u, const char *name, int len)
goto done;
}
# endif
- ret = (strcmp(path, u->filename) == 0);
+ if (u->filename)
+ ret = (strcmp(path, u->filename) == 0);
+ else
+ ret = 0;
#endif
done:
free (path);
@@ -1570,7 +1573,7 @@ find_file0 (gfc_unit *u, FIND_FILE0_DECL)
}
else
# endif
- if (strcmp (u->filename, path) == 0)
+ if (u->filename && strcmp (u->filename, path) == 0)
return u;
#endif