Re: [PATCH] fixincludes: don't assume getcwd() can handle NULL argument

2021-11-11 Thread Jeff Law via Gcc-patches
On 11/11/2021 6:04 AM, Eric Gallager via Gcc-patches wrote: On Tue, Nov 9, 2021 at 8:50 AM Xi Ruoyao via Gcc-patches wrote: POSIX says: On some implementations, if buf is a null pointer, getcwd() may obtain size bytes of memory using malloc(). In this case, the pointer returned

Re: [PATCH] fixincludes: don't assume getcwd() can handle NULL argument

2021-11-11 Thread Eric Gallager via Gcc-patches
On Tue, Nov 9, 2021 at 8:50 AM Xi Ruoyao via Gcc-patches wrote: > > POSIX says: > > On some implementations, if buf is a null pointer, getcwd() may obtain > size bytes of memory using malloc(). In this case, the pointer returned > by getcwd() may be used as the argument in a

Re: [PATCH] fixincludes: don't assume getcwd() can handle NULL argument

2021-11-10 Thread Bruce Korb via Gcc-patches
On 11/10/21 4:22 AM, Xi Ruoyao wrote: Isn't this warning actually a glibc bug ? However we can't assume the libc we are using is Glibc. Even if the libc supports getcwd() with NULL argument, we are still leaking memory. You could also free

Re: [PATCH] fixincludes: don't assume getcwd() can handle NULL argument

2021-11-10 Thread Xi Ruoyao via Gcc-patches
On Wed, 2021-11-10 at 00:02 +, Joseph Myers wrote: > On Tue, 9 Nov 2021, Xi Ruoyao via Gcc-patches wrote: > > > POSIX says: > > > >     On some implementations, if buf is a null pointer, getcwd() may > > obtain > >     size bytes of memory using malloc(). In this case, the pointer > >

Re: [PATCH] fixincludes: don't assume getcwd() can handle NULL argument

2021-11-09 Thread Joseph Myers
On Tue, 9 Nov 2021, Xi Ruoyao via Gcc-patches wrote: > POSIX says: > > On some implementations, if buf is a null pointer, getcwd() may obtain > size bytes of memory using malloc(). In this case, the pointer returned > by getcwd() may be used as the argument in a subsequent call to

[PATCH] fixincludes: don't assume getcwd() can handle NULL argument

2021-11-09 Thread Xi Ruoyao via Gcc-patches
POSIX says: On some implementations, if buf is a null pointer, getcwd() may obtain size bytes of memory using malloc(). In this case, the pointer returned by getcwd() may be used as the argument in a subsequent call to free(). Invoking getcwd() with buf as a null pointer is not