1
0
Fork 1

disconnect_client: fix index calculation

This was sometimes causing a gmnisrv_client to be overwritten by the
deinitialized client, which occasionally lead to a segfault when we
later tried to use it.
This commit is contained in:
Eyal Sawady 2021-05-16 15:53:47 -04:00 committed by Drew DeVault
parent 53e4ce4abd
commit b9a92193e9
1 changed files with 1 additions and 1 deletions

View File

@ -200,7 +200,7 @@ disconnect_client(struct gmnisrv_server *server, struct gmnisrv_client *client)
free(client->path);
client->path = NULL;
size_t index = (client - server->clients) / sizeof(struct gmnisrv_client);
size_t index = client - server->clients;
memmove(&server->clients[index],
&server->clients[index + 1],
(server->clientsz - (index + 1)) * sizeof(struct gmnisrv_client));