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

Eirik Byrkjeflot Anonsen eirik at eirikba.org
Thu May 21 11:35:32 PDT 2015


walter harms <wharms at bfs.de> writes:

> Am 21.05.2015 14:55, schrieb Eirik Byrkjeflot Anonsen:
>> Signed-off-by: Eirik Byrkjeflot Anonsen <eirik at eirikba.org>
>> ---
>>  xprop.c | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>> 
>> diff --git a/xprop.c b/xprop.c
>> index 7e1e719..f14eec2 100644
>> --- a/xprop.c
>> +++ b/xprop.c
>> @@ -755,10 +755,17 @@ is_utf8_locale (void)
>>  static const char *
>>  Format_Icons (const unsigned long *icon, int len)
>>  {
>> -    char *result = NULL, *tail = NULL;
>> +    static char *result = NULL;
>> +    char *tail = NULL;
>>      int alloced;
>>      const unsigned long *end = icon + len / sizeof (unsigned long);
>>  
>> +    if (result)
>> +    {
>> +	free(result);
>> +	result = NULL;
>> +    }
>> +
>
> let free() handle NULL
>
> re,
>  wh

Yes, sounds sensible. Not sure why I added the test there.

eirik


More information about the xorg-devel mailing list