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 <chris2553@googlemail.com> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
94d4e29aed
commit
1110b71e36
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue