Fix channel use after freeing in main loop - ii - irc it, simple FIFO based irc… | |
git clone git://git.suckless.org/ii | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit f79e2f09534d92a6fe4e062b06449a925fef1c41 | |
parent 165638e3c81213956a6b41d5889ba05186f4f771 | |
Author: Vasily Kolobkov <[email protected]> | |
Date: Sun, 14 Feb 2016 13:07:17 +0200 | |
Fix channel use after freeing in main loop | |
Signed-off-by: Nico Golde <[email protected]> | |
Diffstat: | |
M ii.c | 6 ++++-- | |
1 file changed, 4 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/ii.c b/ii.c | |
@@ -418,7 +418,7 @@ static void handle_server_output() { | |
} | |
static void run() { | |
- Channel *c; | |
+ Channel *c, *n; | |
int r, maxfd; | |
fd_set rd; | |
struct timeval tv; | |
@@ -455,9 +455,11 @@ static void run() { | |
handle_server_output(); | |
last_response = time(NULL); | |
} | |
- for(c = channels; c; c = c->next) | |
+ for(c = channels; c; c = n) { | |
+ n = c->next; | |
if(FD_ISSET(c->fd, &rd)) | |
handle_channels_input(c); | |
+ } | |
} | |
} | |