[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] another getcwd fix (includes previous patch)



Hello, Alan.

Another problem with getcwd() is that it defines a variable sized buffer
for _path (which is non-ANSI as the note says).

With gcc optimizations this gets messed up and crashes, probably due to
stack corruption.

The variable sized array is non-ANSI, however it shouldn't crash !
It may be a GCC bug, a MiNTLib bug, or once again a stack overflow !

If the size passed to __getcwd() is too big, the original version will allocate a buffer of that size on the stack, and may crash. You version uses malloc, so it is safer.

However, it would be interesting to know exactly what was the cause of the crash. Did you manage to make a small testcase reproducing that problem ?

--
Vincent Rivière