Commit 44d0fd43 authored by Egbert Eich's avatar Egbert Eich Committed by Adam Jackson

kdrive/UnregisterFd: Fix off by one

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 1110b71e
  Author: Chris Clayton <>

    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: 's avatarEgbert Eich <>
Reviewed-by: 's avatarPeter Hutterer <>
parent eb36924e
...@@ -220,9 +220,9 @@ KdUnregisterFd(void *closure, int fd, Bool do_close) ...@@ -220,9 +220,9 @@ KdUnregisterFd(void *closure, int fd, Bool do_close)
KdRemoveFd(kdInputFds[i].fd); KdRemoveFd(kdInputFds[i].fd);
if (do_close) if (do_close)
close(kdInputFds[i].fd); close(kdInputFds[i].fd);
for (j = i; j < (kdNumInputFds - 1); j++) for (j = i; j < (kdNumInputFds - 1); j++)
kdInputFds[j] = kdInputFds[j + 1]; kdInputFds[j] = kdInputFds[j + 1];
break; break;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment