1
0
forked from aniani/gmnisrv

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); free(client->path);
size_t index = (client - server->clients) / sizeof(struct gmnisrv_client); 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], memmove(&server->fds[server->nlisten + index],
&server->fds[server->nlisten + index + 1], &server->fds[server->nlisten + index + 1],
(server->fdsz - (server->nlisten + index + 1)) * sizeof(struct pollfd)); (server->fdsz - (server->nlisten + index + 1)) * sizeof(struct pollfd));