[PATCH xserver] kdrive/UnregisterFd: Fix off by one
Peter Hutterer
peter.hutterer at who-t.net
Tue Nov 24 13:40:44 PST 2015
On Tue, Nov 24, 2015 at 05:37:36PM +0100, Egbert Eich wrote:
> From: Egbert Eich <eich at suse.de>
>
> The number of FDs has been decremented already, therefore the
> number contained the index of the top one that is to me moved down.
>
> This problem was introduced by:
> commit 1110b71e360195aab040d835b54540ab558638c5
> Author: Chris Clayton <chris2553 at googlemail.com>
>
> kdrive: fix build error on gcc 4.8 for out-of-bounds array access
>
> The reason for the warning was likely a confused compiler.
> Hoping to reduce the confusion by moving the decrement behind the end
> if the copy loop.
>
> Signed-off-by: Egbert Eich <eich at suse.de>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Cheers,
Peter
> ---
> hw/kdrive/src/kinput.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
> index 4bb9315..d5741f1 100644
> --- a/hw/kdrive/src/kinput.c
> +++ b/hw/kdrive/src/kinput.c
> @@ -220,9 +220,9 @@ KdUnregisterFd(void *closure, int fd, Bool do_close)
> KdRemoveFd(kdInputFds[i].fd);
> if (do_close)
> close(kdInputFds[i].fd);
> - kdNumInputFds--;
> for (j = i; j < (kdNumInputFds - 1); j++)
> kdInputFds[j] = kdInputFds[j + 1];
> + kdNumInputFds--;
> break;
> }
> }
> --
> 2.5.3
>
> _______________________________________________
> 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