Hi,

the attached patch fixes a null pointer crash on the mingw target (or
to be precise, targets where HAVE_WORKING_STAT is not defined).

Committed as obvious to trunk as r225788.

Richi, is this Ok for 5.2?


2015-07-14  Janne Blomqvist  <j...@gcc.gnu.org>

    PR libfortran/66861
    * io/unix.c (compare_file_filename): Verify that u->filename is
    non-NULL before strcmp.
    (find_file0): Likewise.


-- 
Janne Blomqvist
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index e5fc6e1..a1ce9a3 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
 

Reply via email to