forked from aniani/gmnisrv
1
0
Fork 0

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
1 changed files with 3 additions and 1 deletions

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));