eggheads / eggdrop

The Eggdrop IRC Bot
GNU General Public License v2.0
500 stars 84 forks source link

Fix memleak in init_channel() #1592

Closed michaelortmann closed 3 months ago

michaelortmann commented 4 months ago

Found by: michaelortmann (or Mystery-X if this fixes #1545, but unlikely, see https://github.com/eggheads/eggdrop/issues/1545#issuecomment-2041046997) Patch by: michaelortmann Fixes:

One-line summary: Fix memleak in init_channel()

Additional description (if needed): init_channel() was only freeing the first element of a linked list Leak is triggered by the bot joining a channel and by use of init_channel(), like with .reset. Fixing this leak could fix #1545, but it could- very likely - be a different leak. We decided to ignore codacity code duplication warning here.

Test cases demonstrating functionality (if applicable): $ valgrind --leak-check=full --show-leak-kinds=all --verbose ./eggdrop -t BotA.conf make the bot join a channel and wait for the who reply .die the leak is shown like: ==320050== by 0x4868D36: init_channel (tclchan.c:2007)

more visually, one could add char debug[1024 * 1024]; to the memberlist stuct in src/chan.c so that every leak would leak 1MB