[PATCH] dix: check for NULL pointer before dereferences it in DeviceEnterLeaveEvent

Jeremy Huddleston jeremyhu at freedesktop.org
Wed Apr 21 12:16:19 PDT 2010


This patch also adds this change which isn't really described by the commit description:

grab = mouse->deviceGrab.grab;

but you forgot to change this:

    GrabPtr             grab = mouse->deviceGrab.grab;
to
    GrabPtr             grab;


On Apr 19, 2010, at 10:58, Tiago Vignatti wrote:

> mouse is already used before its checking should be performed. So check on the
> beginning instead.
> ---
> dix/events.c |    6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/dix/events.c b/dix/events.c
> index 6541652..8bec8af 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -4360,6 +4360,10 @@ DeviceEnterLeaveEvent(
>         (mode == XINotifyPassiveUngrab && type == XI_Enter))
>         return;
> 
> +    if (!mouse)
> +        return;
> +    grab = mouse->deviceGrab.grab;
> +
>     btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
>     btlen = bytes_to_int32(btlen);
>     len = sizeof(xXIEnterEvent) + btlen * 4;
> @@ -4378,7 +4382,7 @@ DeviceEnterLeaveEvent(
>     event->root_x       = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
>     event->root_y       = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
> 
> -    for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
> +    for (i = 0; mouse->button && i < mouse->button->numButtons; i++)
>         if (BitIsOn(mouse->button->down, i))
>             SetBit(&event[1], i);
> 
> -- 
> 1.6.0.4
> 
> _______________________________________________
> 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