[PATCH] Xi: check for NULL pointer before dereferences it in ListButtonInfo

Dan Nicholson dbn.lists at gmail.com
Sat Apr 17 08:24:58 PDT 2010


On Fri, Apr 16, 2010 at 8:42 AM, Tiago Vignatti
<tiago.vignatti at nokia.com> wrote:
> Both dev and dev->button are already used before their checking were being
> performed. So check on the beginning.
>
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
>  Xi/xiquerydevice.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
> index 435868d..a4bbc2e 100644
> --- a/Xi/xiquerydevice.c
> +++ b/Xi/xiquerydevice.c
> @@ -247,6 +247,9 @@ ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info, Bool reportState)
>     int mask_len;
>     int i;
>
> +    if (!dev || !dev->button)
> +       return BadValue;

This function returns "Number of bytes written into info". So, this
will just make it return 2 and the caller will carry on normally. It
should probably return 0 so the caller thinks it can't write any bytes
here. Otherwise, looks good.

--
Dan


More information about the xorg-devel mailing list