[PATCH 07/11] Xi: fix memory leak in ProcXGetSelectedExtensionEvents

Alan Coopersmith alan.coopersmith at oracle.com
Fri Mar 25 16:26:30 PDT 2011


On 03/25/11 05:12 PM, Nicolas PENINGUY wrote:
> On Fri, 2011-03-25 at 20:41 +0200, Tiago Vignatti wrote:
>> diff --git a/Xi/getselev.c b/Xi/getselev.c
>> index 09a53f4..7304738 100644
>> --- a/Xi/getselev.c
>> +++ b/Xi/getselev.c
>> @@ -152,8 +152,8 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
>>      if (total_length) {
>>  	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
>>  	WriteSwappedDataToClient(client, total_length, buf);
>> -	free(buf);
>>      }
>> +    free(buf);
>>      return Success;
>>  }
> 
> I think this one isn't necessary, as it only change behaviour when doing
> malloc(0)...

The C89 & C99 standards allow implementations to choose whether malloc(0)
returns NULL or a valid pointer to a block of memory that needs to be
free()d to avoid leaking.   At least some platforms X used to be supported
on had different implementations, as we did have code in imake and still
have checks in our autoconf macros to see which method is used.

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list