From 1110b71e360195aab040d835b54540ab558638c5 Mon Sep 17 00:00:00 2001 From: Chris Clayton Date: Wed, 4 Sep 2013 15:42:04 +1000 Subject: kdrive: fix build error on gcc 4.8 for out-of-bounds array access I'm getting a error building xorg-server-1.14.1.902 with thelatest snapshot of gcc-4.8: input.c:225:43: error: array subscript is above array bounds [-Werror=array-bounds] This is because kdNumInputFds can become equal to KD_MAX_INPUT_FDS in KdRegisterFd(). This means that in KdUnregisterFd(), kdInputFds[j + 1] can be beyond the end of the array. Signed-off-by: Chris Clayton Reviewed-by: Keith Packard Signed-off-by: Peter Hutterer --- hw/kdrive/src/kinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index f93830eb1..527c7a2ef 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -221,7 +221,7 @@ KdUnregisterFd(void *closure, int fd, Bool do_close) if (do_close) close(kdInputFds[i].fd); kdNumInputFds--; - for (j = i; j < kdNumInputFds; j++) + for (j = i; j < (kdNumInputFds - 1); j++) kdInputFds[j] = kdInputFds[j + 1]; break; } -- cgit v1.2.3