From: Janne Blomqvist Date: Tue, 14 Jul 2015 20:26:06 +0000 (+0300) Subject: PR 66861 Fix null pointer crash on mingw. X-Git-Tag: basepoints/gcc-7~5674 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5fd6ec3e4b29ed0e4ba1ca81d642ee718004db7d;p=thirdparty%2Fgcc.git PR 66861 Fix null pointer crash on mingw. 2015-07-14 Janne Blomqvist PR libfortran/66861 * io/unix.c (compare_file_filename): Verify that u->filename is non-NULL before strcmp. (find_file0): Likewise. From-SVN: r225788 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index ae0d85328c79..876b2c92f8a4 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2015-07-14 Janne Blomqvist + + PR libfortran/66861 + * io/unix.c (compare_file_filename): Verify that u->filename is + non-NULL before strcmp. + (find_file0): Likewise. + 2015-07-06 Francois-Xavier Coudert PR libfortran/40267 diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index e5fc6e19818d..a1ce9a3ffe7e 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