[Xcb] Patch to fix memory leak.

Ian Osgood iano at quirkster.com
Wed Aug 6 12:50:27 PDT 2008


The patch is wrong. You need to set hints to NULL, not rep.

Ian

On Aug 6, 2008, at 12:39 PM, Barton C Massey wrote:

> Thanks much for the patch!
>
> However, excuse my naivete, but is this the best patch?
> Wouldn't it have been better to just add the single
> free(rep) line at the end?  Thanks also for any
> clarification you might have.
>
>     Bart
>
> In message <mailman.35.1218049216.17565.xcb- 
> commit at lists.freedesktop.org> you wrote:
>> New commits:
>> commit 73d2e818e5a4ec362061cd95031a0cf2d8d02f96
>> Author: Julien Danjou <julien at danjou.info>
>> Date:   Wed Aug 6 16:23:36 2008 +0200
>>
>>     icccm: fix memory leak in xcb_get_wm_hints()
>>
>>     Signed-off-by: Julien Danjou <julien at danjou.info>
>>
>> diff --git a/icccm/icccm.c b/icccm/icccm.c
>> index ff89d3e..250c4c3 100644
>> --- a/icccm/icccm.c
>> +++ b/icccm/icccm.c
>> @@ -670,7 +670,7 @@ xcb_get_wm_hints (xcb_connection_t *c,
>>                    xcb_window_t      window)
>>  {
>>  	xcb_get_property_cookie_t cookie;
>> -	xcb_get_property_reply_t *rep;
>> +	xcb_get_property_reply_t *rep = NULL;
>>  	xcb_wm_hints_t           *hints;
>>  	long                      length;
>>
>> @@ -685,22 +685,19 @@ xcb_get_wm_hints (xcb_connection_t *c,
>>  	if ((rep->type != WM_HINTS) ||
>>  	    (length < (XCB_NUM_WM_HINTS_ELEMENTS - 1)) ||
>>  	    (rep->format != 32))
>> -	{
>> -		free (rep);
>> -		return NULL;
>> -	}
>> +            goto bailout;
>> +
>>  	hints = xcb_alloc_wm_hints();
>>  	if (!hints)
>> -	{
>> -		free (rep);
>> -		return NULL;
>> -	}
>> +            goto bailout;
>>
>>  	memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value (rep),
>>  	       length * rep->format >> 3);
>>  	if (length < XCB_NUM_WM_HINTS_ELEMENTS)
>>  		hints->window_group = XCB_NONE;
>>
>> +    bailout:
>> +        free(rep);
>>  	return hints;
>>  }
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb




More information about the Xcb mailing list