hirc

IRC client
Log | Files | Refs

commit b68c3f2f1850b4339e9d166f5c8458a558f0e4aa
parent a28f4eb46de7b702f42e438b56bde7745ea521f9
Author: hhvn <dev@hhvn.uk>
Date:   Mon, 13 Dec 2021 17:04:44 +0000

s/main.c: don't segfault on quit with multiple servers

Diffstat:
Msrc/main.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -58,14 +58,16 @@ estrdup(const char *str) { void cleanup(char *quitmsg) { - struct Server *sp; + struct Server *sp, *prev; - for (sp = servers; sp; sp = sp->next) { - if (sp->prev) - serv_free(sp->prev); + for (sp = servers, prev = NULL; sp; sp = sp->next) { + if (prev) + serv_free(prev); serv_disconnect(sp, 0, quitmsg); + prev = sp; } + serv_free(prev); ui_deinit(); }