Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2005-04-24 01:41:11 UTC

Modified files:
     ChangeLog ircd/channel.c ircd/ircd_parser.y

Log message:

Fix memory leaks when removing bans or applying overlapped bans.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.611 ircu2.10/ChangeLog:1.612
--- ircu2.10/ChangeLog:1.611    Sat Apr 23 17:17:38 2005
+++ ircu2.10/ChangeLog  Sat Apr 23 18:41:00 2005
@@ -1,5 +1,13 @@
 2005-04-23  Michael Poole <[EMAIL PROTECTED]>
 
+       * ircd/channel.c (apply_ban): Consistently free newban->banstr
+       when the function fails.
+       (mode_process_bans): Free banstr for all BAN_DEL bans.
+
+       * ircd/ircd_parser.y: Fix a few memory leaks from previous commit.
+
+2005-04-23  Michael Poole <[EMAIL PROTECTED]>
+
        * include/patchlevel.h: Bump to being a beta.
 
        * ircd/ircd_lexer.l (QSTRING): Return a copy of the string so that
Index: ircu2.10/ircd/channel.c
diff -u ircu2.10/ircd/channel.c:1.126 ircu2.10/ircd/channel.c:1.127
--- ircu2.10/ircd/channel.c:1.126       Fri Apr 22 16:36:30 2005
+++ ircu2.10/ircd/channel.c     Sat Apr 23 18:41:00 2005
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief Channel management and maintenance
- * @version $Id: channel.c,v 1.126 2005/04/22 23:36:30 entrope Exp $
+ * @version $Id: channel.c,v 1.127 2005/04/24 01:41:00 entrope Exp $
  */
 #include "config.h"
 
@@ -2696,6 +2696,8 @@
       if (!bmatch(ban, newban)) {
         if (do_free)
           free_ban(newban);
+        else
+          MyFree(newban->banstr);
         return 1;
       }
       if (!(ban->flags & (BAN_OVERLAPPED|BAN_DEL))) {
@@ -2732,6 +2734,8 @@
   }
   if (do_free)
     free_ban(newban);
+  else
+    MyFree(newban->banstr);
   return 4;
 }
 
@@ -2890,6 +2894,13 @@
     prevban = ban;
   } /* for (prevban = 0, ban = state->chptr->banlist; ban; ban = nextban) { */
 
+  /* Release all masks of removed bans */
+  for (count = 0; count < state->numbans; ++count) {
+    ban = state->banlist + count;
+    if (ban->flags & BAN_DEL)
+      MyFree(ban->banstr);
+  }
+
   if (changed) /* if we changed the ban list, we must invalidate the bans */
     mode_ban_invalidate(state->chptr);
 }
Index: ircu2.10/ircd/ircd_parser.y
diff -u ircu2.10/ircd/ircd_parser.y:1.49 ircu2.10/ircd/ircd_parser.y:1.50
--- ircu2.10/ircd/ircd_parser.y:1.49    Sat Apr 23 17:17:39 2005
+++ ircu2.10/ircd/ircd_parser.y Sat Apr 23 18:41:01 2005
@@ -17,7 +17,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  *  USA.
- * $Id: ircd_parser.y,v 1.49 2005/04/24 00:17:39 entrope Exp $
+ * $Id: ircd_parser.y,v 1.50 2005/04/24 01:41:01 entrope Exp $
  */
 %{
 
@@ -441,6 +441,7 @@
 connectclass: CLASS '=' QSTRING ';'
 {
  c_class = find_class($3);
+ MyFree($3);
 };
 connecthost: HOST '=' QSTRING ';'
 {
@@ -936,10 +937,12 @@
 pseudoitem: pseudoname | pseudoprepend | pseudonick | pseudoflags | error;
 pseudoname: NAME '=' QSTRING ';'
 {
+  MyFree(smap->name);
   smap->name = $3;
 };
 pseudoprepend: PREPEND '=' QSTRING ';'
 {
+  MyFree(smap->prepend);
   smap->prepend = $3;
 };
 pseudonick: NICK '=' QSTRING ';'
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
Patches@undernet.org
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to