This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, libfortran] Some path handling fixes
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Fortran List <fortran at gcc dot gnu dot org>
- Date: Fri, 29 Apr 2011 08:55:05 -0700
- Subject: Re: [Patch, libfortran] Some path handling fixes
- References: <BANLkTikKTk7rrO5EVfG4aAWUGKwQyHqLVw@mail.gmail.com>
On Fri, Apr 29, 2011 at 06:20:17PM +0300, Janne Blomqvist wrote:
>
> since about a decade or so ago, POSIX specifies that PATH_MAX includes
> the trailing null byte (previously it was undefined). However,
> libgfortran has incorrectly assumed the opposite, and has thus created
> temporary buffers of length PATH_MAX + 1 for holding paths when
> converting from Fortran to C style strings. Secondly, these buffers
> are allocated on the stack, and on Linux PATH_MAX is 4096 (presumably
> other targets use something similar), which is quite a large object to
> put on the stack. This can however be easily avoided in the common
> case by using VLA's or alloca() as most paths are quite short, and we
> know the size of the Fortran string to convert.
>
> The attached patch fixes the problems discussed above. Regtested on
> x86_64-unknown-linux-gnu, Ok for trunk?
>
OK.
--
Steve