On 04/29/2011 08:20 AM, Janne Blomqvist wrote:
Hello all,

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 and thanks for the patch.

Jerry

Reply via email to