On 10/29/24 04:29, Walter Harms wrote:
hello,
if i rember correctly there is a whole wrapper for malloc in libX11.

It's a pretty thin wrapper - just a #define which varies depending on the
setting of XORG_CHECK_MALLOC_ZERO:

https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/libX11-1.8.10/include/X11/Xlibint.h?ref_type=tags#L449-467

Beside that i would suggest something like
EXPECTED_GLIBC_BEHAVIER (default)
or you are on your own otherwise you start to fix a bunch of errors in these 
wrappers.
ppl that use LD_PRELOAD simply should know what they are doing.

glibc is only one of the libc implementations we need to deal with.
It's only used on Linux, and even on Linux there's several other options.

How often may malloc(0) occur ?

Enough that I've had to fix several compiler errors & warnings from it when
enabling this option:

https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/266
https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/267

 glibc says it will return a valid pointer, i thing that reasonable and easy to 
check.

But neither the C standard nor POSIX require it, and this macro exists because
not all libc implementations do return a valid pointer.

--
        -Alan Coopersmith-                 alan.coopersm...@oracle.com
         Oracle Solaris Engineering - https://blogs.oracle.com/solaris

Reply via email to