[PATCH 2/6] xserver: Possible memory leaks, stricter option checks, UnInit (NewInputDeviceRequest)

Alan Coopersmith alan.coopersmith at sun.com
Fri Mar 30 10:26:34 PDT 2007


Eirik Byrkjeflot Anonsen wrote:
> Alan Coopersmith <alan.coopersmith at sun.com> writes:
> 
>> Magnus Vigerlöf wrote:
>>> On Thursday 29 March 2007 04:40, Eric Anholt wrote:
>>> [...]
>>>>> I guess xfree can't handle freeing already NULL pointers?  If so it
>>>>> could cleanup error paths like this a little.  Looks good though.
>>>> The first thing Xfree (what xfree() is) does is check if the pointer is
>>>> null and return if so.
>>> You're right. Xfree (and free as well) does seem to handle
>>> this. However many places this check is made in the code anyway, and
>>> there's a comment complaining about this 0-pointer check in Xfree as
>>> well..
>> And ANSI C requires free(NULL) to be a safe no-op anyways, so it's not
>> needed at all on modern OS'es.
>>
> 
> But I don't think xfree(NULL) is guaranteed to be safe.  And I doubt
> that xfree(NULL) is specified as being "as safe as" free(NULL).

We define xfree(), so what stops us from raising xfree(NULL) from
"Undefined" to "Guaranteed safe no-op"?   All we have to do is document
it - it won't break anything that works already.   (If you want to
kill the process, call abort(), not Xfree(NULL) and hope it segfaults.)

-- 
	-Alan Coopersmith-           alan.coopersmith at sun.com
	 Sun Microsystems, Inc. - X Window System Engineering




More information about the xorg mailing list