[PATCH v2 2/4] Free the data returned by XGetWindowProperty()

Eirik Byrkjeflot Anonsen eirik at eirikba.org
Thu May 21 11:31:27 PDT 2015


walter harms <wharms at bfs.de> writes:

> maybe this was the case in older versions.
> a current free() should accept NULL.
>
> Xfree is onyl a wrapper for free()
> #define Xfree(ptr) free((ptr))

It depends on whether you talk about the function XFree() as defined by
the X11 specification or the particular version of XFree() as
implemented by x.org. The X11 function is not safe to use with NULL,
while x.org's implementation happens to handle it. I think it makes
sense to follow the specification here and not pass NULL to XFree().

eirik

>
> Am 21.05.2015 19:02, schrieb Jasper St. Pierre:
>> I thought I remembered something which tried to poke the pointer first
>> to make it crash if it was NULL, since freeing of a NULL pointer was
>> considered a bug.
>> 
>> On Thu, May 21, 2015 at 9:34 AM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
>>> On 21 May 2015 at 17:21, Jasper St. Pierre <jstpierre at mecheye.net> wrote:
>>>> XFree crashes when passed NULL.
>>>>
>>> I've never tried it personally, but it seems that XFree() is a simple
>>> wrapper around free(), which should work just fine. [1] [2]
>>> On the other hand $ man 3 XFree clearly states that "NULL pointer
>>> cannot be passed to this function" :-\
>
>
> the documentation need a fix.
>
>
>>> -Emil
>>>
>>> [1] http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/XlibInt.c#n1546
>>> [2] http://cgit.freedesktop.org/xorg/lib/libX11/tree/include/X11/Xlibint.h#n332
>> 
>> 
>> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list