diff options
| author | Nakidai <nakidai@disroot.org> | 2026-02-10 21:25:47 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2026-02-10 21:25:47 +0300 |
| commit | 204e8f8b2282a476d5f2b97abee0d81c119dd6bf (patch) | |
| tree | a8d40a0c5250af4c5c7402d5157425279f68a9bd /user.c | |
| parent | 7d51a93567e7f1e70a0e7f006bdf8a248f94d1ee (diff) | |
| download | libreircd-204e8f8b2282a476d5f2b97abee0d81c119dd6bf.tar.gz libreircd-204e8f8b2282a476d5f2b97abee0d81c119dd6bf.zip | |
Fix channel_exit()ing user_remove()
When user user_remove() is called, that user quits all of the channels it was belonging to. But since channel_exit() mutates chanels array, it is incorrect to 1) compare with channels_c 2) access channels[i]. As a fix, 1) channels_c is not being compared throughout the loop but is assigned to i once, and then i decrements 2) channels is being accessed only as channels[0]
Diffstat (limited to 'user.c')
| -rw-r--r-- | user.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/user.c b/user.c index 5d9bc15..0932b0e 100644 --- a/user.c +++ b/user.c @@ -91,8 +91,8 @@ user_remove(size_t pid) struct Peer *last; size_t i, j; - for (i = 0; i < peers[pid].channels_c; ++i) - channel_exit(peers[pid].channels[i], &peers[pid]); + for (i = peers[pid].channels_c; i; --i) + channel_exit(peers[pid].channels[0], &peers[pid]); last = &peers[peers_c-1]; for (i = 0; i < last->channels_c; ++i) |