From 0f18525a2cbc77d1d0be26706dbe922cd1765f82 Mon Sep 17 00:00:00 2001 From: "certus certus@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Thu, 2 Mar 2006 08:55:57 +0000 Subject: [PATCH] # BUILD : 1.7.13 (999) # BUGS : 430 # NOTES : Fixed memleak in do_cmode() git-svn-id: svn://svn.anope.org/anope/trunk@999 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@724 5417fbe8-f217-4b02-8779-1006273d7864 --- Changes | 1 + src/channels.c | 35 +++++++++++++++++++++++++++++++---- version.log | 8 ++++++-- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index d765c4823..bfb3dbafc 100644 --- a/Changes +++ b/Changes @@ -30,6 +30,7 @@ Provided by Anope Dev. - 2006 03/01 F Fixed memleaks in hs_set.c. [#441] 04/01 F Fixed missing TS6 functionality in channels.c. [#418] 04/01 F Fixed possible overflow in process(). [#445] +04/01 F Fixed memleak in do_cmode(). [#430] Provided by nenolod. - 2006 02/03 A Support for Charybdis IRCd. [ #00] diff --git a/src/channels.c b/src/channels.c index 5ed5758c8..8191eccd3 100644 --- a/src/channels.c +++ b/src/channels.c @@ -1101,7 +1101,7 @@ void do_cmode(const char *source, int ac, char **av) { Channel *chan; ChannelInfo *ci = NULL; - int i; + int i, tofree0 = 0, tofree1 = 0, tofree2 = 0; char *t; if (ircdcap->tsmode) { @@ -1133,9 +1133,24 @@ void do_cmode(const char *source, int ac, char **av) if (debug) { alog("debug: Before TS6 swap: do_cmode() chan %s : mode %s : extra %s", av[1], av[2], av[3]); } - av[0] = (ac >= 2 ? sstrdup(av[1]) : NULL); - av[1] = (ac >= 3 ? sstrdup(av[2]) : NULL); - av[2] = (ac >= 4 ? sstrdup(av[3]) : NULL); + if (ac >= 2) { + av[0] = sstrdup(av[1]); + tofree0 = 1; + } else { + av[0] = NULL; + } + if (ac >= 3) { + av[1] = sstrdup(av[2]); + tofree1 = 1; + } else { + av[1] = NULL; + } + if (ac >= 4) { + av[2] = sstrdup(av[3]); + tofree2 = 1; + } else { + av[2] = NULL; + } if (debug) { alog("debug: After TS swap: do_cmode() chan %s : mode %s : extra %s", av[0], av[1], av[2]); } @@ -1154,6 +1169,12 @@ void do_cmode(const char *source, int ac, char **av) alog("debug: MODE %s for nonexistent channel %s", merge_args(ac - 1, av + 1), av[0]); } + if (tofree0) + free(av[0]; + if (tofree1) + free(av[1]; + if (tofree2) + free(av[2]; return; } @@ -1169,6 +1190,12 @@ void do_cmode(const char *source, int ac, char **av) ac--; av++; chan_set_modes(source, chan, ac, av, 1); + if (tofree1) + free(av[0]; + if (tofree2) + free(av[1]; + if (tofree3) + free(av[2]; } /*************************************************************************/ diff --git a/version.log b/version.log index 6f5d60078..d2b730b98 100644 --- a/version.log +++ b/version.log @@ -9,13 +9,17 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="13" VERSION_EXTRA="-svn" -VERSION_BUILD="998" +VERSION_BUILD="999" # $Log$ # +# BUILD : 1.7.13 (999) +# BUGS : 430 +# NOTES : Fixed memleak in do_cmode() +# # BUILD : 1.7.13 (998) # BUGS : 445 -# NOTES : Tixed possible overflow in process() +# NOTES : Fixed possible overflow in process() # # BUILD : 1.7.13 (997) # BUGS : 418