diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2014-05-22 06:51:25 +0300 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2014-05-22 06:51:25 +0300 |
commit | 4269f19c09163d6ef65043171eeccc9c521d9b5f (patch) | |
tree | b97492f2a8d9b9b3d41f020dde39ac89bad83229 /libgfortran/io/open.c | |
parent | d5c67efda0d5e2d42abd49c0d58bb39a038d20ec (diff) | |
download | gcc-4269f19c09163d6ef65043171eeccc9c521d9b5f.zip gcc-4269f19c09163d6ef65043171eeccc9c521d9b5f.tar.gz gcc-4269f19c09163d6ef65043171eeccc9c521d9b5f.tar.bz2 |
PR 60324 Handle long path names, don't use PATH_MAX.
From-SVN: r210738
Diffstat (limited to 'libgfortran/io/open.c')
-rw-r--r-- | libgfortran/io/open.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index 06fd594..b803859 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -502,12 +502,9 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags) s = open_external (opp, flags); if (s == NULL) { - char *path, *msg; - size_t msglen; - path = (char *) gfc_alloca (opp->file_len + 1); - msglen = opp->file_len + 51; - msg = (char *) gfc_alloca (msglen); - unpack_filename (path, opp->file, opp->file_len); + char *path = fc_strdup (opp->file, opp->file_len); + size_t msglen = opp->file_len + 51; + char *msg = xmalloc (msglen); switch (errno) { @@ -529,10 +526,13 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags) break; default: + free (msg); msg = NULL; } generate_error (&opp->common, LIBERROR_OS, msg); + free (msg); + free (path); goto cleanup; } @@ -676,15 +676,6 @@ already_open (st_parameter_open *opp, gfc_unit * u, unit_flags * flags) if (!compare_file_filename (u, opp->file, opp->file_len)) { -#if !HAVE_UNLINK_OPEN_FILE - char *path = NULL; - if (u->file && u->flags.status == STATUS_SCRATCH) - { - path = (char *) gfc_alloca (u->file_len + 1); - unpack_filename (path, u->file, u->file_len); - } -#endif - if (sclose (u->s) == -1) { unlock_unit (u); @@ -699,8 +690,14 @@ already_open (st_parameter_open *opp, gfc_unit * u, unit_flags * flags) u->file_len = 0; #if !HAVE_UNLINK_OPEN_FILE + char *path = NULL; + if (u->file && u->flags.status == STATUS_SCRATCH) + path = fc_strdup (u->file, u->file_len); if (path != NULL) - unlink (path); + { + unlink (path); + free (path); + } #endif u = new_unit (opp, u, flags); |