[PATCH] dix/resource: bug out if we get 0 type resource added

Peter Hutterer peter.hutterer at who-t.net
Mon Dec 3 21:23:04 PST 2012


On Tue, Dec 04, 2012 at 01:06:13PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> With the missing RRProviderInit, we were adding 0 typed resources,
> which crashed when xrestop hit them, we should warn before that happens
> so future developers spot the problem.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

though you should probably check for type == RT_NONE, just for correctness.

Cheers,
   Peter

> ---
>  dix/resource.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/dix/resource.c b/dix/resource.c
> index 2aafa34..144fe23 100644
> --- a/dix/resource.c
> +++ b/dix/resource.c
> @@ -793,6 +793,7 @@ AddResource(XID id, RESTYPE type, pointer value)
>      ClientResourceRec *rrec;
>      ResourcePtr res, *head;
>  
> +    BUG_RETURN_VAL_MSG(type == 0, FALSE, "Illegal to allocate resources with type 0\n");
>  #ifdef XSERVER_DTRACE
>      XSERVER_RESOURCE_ALLOC(id, type, value, TypeNameString(type));
>  #endif
> -- 
> 1.7.11.7
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list