1
0
mirror of https://git.sr.ht/~sircmpwn/gmnisrv synced 2024-11-03 06:07:17 -05:00

Don't memmove one past clients

This commit is contained in:
Tom Lebreux 2020-11-07 07:56:48 -05:00 committed by Drew DeVault
parent d20caf389b
commit 7aedbed774

View File

@ -197,7 +197,9 @@ disconnect_client(struct gmnisrv_server *server, struct gmnisrv_client *client)
free(client->path);
size_t index = (client - server->clients) / sizeof(struct gmnisrv_client);
memmove(client, &client[1], &server->clients[server->clientsz] - client);
memmove(&server->clients[index],
&server->clients[index + 1],
(server->clientsz - (index + 1)) * sizeof(struct gmnisrv_client));
memmove(&server->fds[server->nlisten + index],
&server->fds[server->nlisten + index + 1],
(server->fdsz - (server->nlisten + index + 1)) * sizeof(struct pollfd));