~sircmpwn/gmni-devel

gmnisrv: disconnect_client: fix index calculation v1 APPLIED

Eyal Sawady: 1
 disconnect_client: fix index calculation

 1 files changed, 1 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/gmni-devel/patches/22748/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gmnisrv] disconnect_client: fix index calculation Export this patch

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.
---
 src/server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/server.c b/src/server.c
index dac772b..e199f6f 100644
--- a/src/server.c
+++ b/src/server.c
@@ -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));
-- 
2.31.1
Nice find. Thanks!

To git@git.sr.ht:~sircmpwn/gmnisrv
   b9a9219..53e4ce4  master -> master