On 04/04/2011 08:54 PM, Tiago Vignatti wrote:
> This seems a good convention to follow: if pointers are allocate outside a
> given function, then free there as well when a failure occurs.
>
> AllocARGBCursor and its callers were mixing up the freeing of resources and
> causing a particular double free inside TileScreenSaver (srcbits and mskbits).
>
> Signed-off-by: Tiago Vignatti<[email protected]>
> ---
> dix/cursor.c | 5 +----
> dix/dispatch.c | 12 +++++++++---
> render/render.c | 12 +++++++++---
> 3 files changed, 19 insertions(+), 10 deletions(-)
>
[...]
> diff --git a/render/render.c b/render/render.c
> index 8ff8ee6..8e58711 100644
> --- a/render/render.c
> +++ b/render/render.c
> @@ -1706,11 +1706,17 @@ ProcRenderCreateCursor (ClientPtr client)
> GetColor(twocolor[1], 0),
> &pCursor, client, stuff->cid);
> if (rc != Success)
> - return rc;
> - if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
> - return BadAlloc;
> + goto bail;
> + if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) {
> + rc = BadAlloc;
> + goto bail;
> + }
>
> return Success;
> +bail:
> + free(srcbits);
> + free(mskbits);
> + return rc;
> }
>
> static int
There are a few return points in ProcRenderCreateCursor that could be
eliminated in the same fashion. But maybe this is more appropriate as a
follow-up patch.
Anyway,
Reviewed-by: Ander Conselvan de Oliveira <[email protected]>
Cheers,
Ander
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel