[PATCH] xserver: input device valuator memory leak

Peter Hutterer mailinglists at who-t.net
Mon Apr 9 16:46:19 PDT 2007


On 10/04/2007, at 06:32 , Magnus Vigerlöf wrote:

> Free the memory allocated for motion history when removing the  
> input device.
> --
> Daniel, if you haven't processed my previous patches, please
> consider adding this one to that batch as well.
>
> Thanks for your hard work.
>  Magnus V
> --
> diff --git a/dix/devices.c b/dix/devices.c
> index c976df0..3e8503e 100644
> --- a/dix/devices.c
> +++ b/dix/devices.c
> @@ -443,8 +443,12 @@ #endif
>  	xfree(dev->key);
>      }
>
> -    if (dev->valuator)
> +    if (dev->valuator) {
> +        /* biggest hack ever 2 (see ~ line 841) */
> +        if(dev->valuator->motion && dev->valuator->GetMotionProc  
> == GetMotionHistory)
> +            xfree(dev->valuator->motion);
>          xfree(dev->valuator);
> +    }
>
>      if (dev->button) {
>  #ifdef XKB

suggestion: set dev->valuator->motion = NULL on device init, then you  
can just call xfree(dev->valuator->motion) rather than duplicating  
the hack. A short grep revealed that motion is either set to the  
motion history or nothing anyway.

Cheers,
   Peter

--
Multi-Pointer X Server
http://wearables.unisa.edu.au/mpx





More information about the xorg mailing list