Patch #6

From: George (greerga@CIRCLEMUD.ORG)
Date: 06/06/98


From Eric Green:

The solution is i suggested doesn't completely work, since d->str is only
allocated for writing by the mail system, not the boards and others.  To
fix this, i just checked if the player was mailing before freeing d->str.
--- 8< --- 8< ---

This should fix the problem with d->str not being freed when a character
loses link while mailing.

diff -upr stk/act.wizard.c 176/act.wizard.c
--- stk/act.wizard.c    Wed May 27 16:47:13 1998
+++ 176/act.wizard.c    Sat Jun  6 19:13:54 1998
@@ -2348,7 +2348,8 @@ int perform_set(struct char_data *ch, st
       send_to_char("No room exists with that number.\r\n", ch);
       return 0;
     }
-    char_from_room(vict);
+    if (IN_ROOM(vict) != NOWHERE)      /* Another Eric Green special. */
+      char_from_room(vict);
     char_to_room(vict, i);
     break;
   case 36:
diff -upr stk/comm.c 176/comm.c
--- stk/comm.c  Wed Apr  1 11:30:59 1998
+++ 176/comm.c  Sat Jun  6 19:25:44 1998
@@ -1521,6 +1521,14 @@ void close_socket(struct descriptor_data
   }

   if (d->character) {
+    /*
+     * Plug memory leak, from Eric Green.
+     */
+    if (PLR_FLAGGED(d->character, PLR_MAILING) && d->str) {
+      if (*(d->str))
+        free(*(d->str));
+      free(d->str);
+    }
     if (STATE(d) == CON_PLAYING || STATE(d) == CON_DISCONNECT) {
       save_char(d->character, NOWHERE);
       act("$n has lost $s link.", TRUE, d->character, 0, 0, TO_ROOM);

--
George Greer, greerga@circlemud.org | Genius may have its limitations, but
http://patches.van.ml.org/          | stupidity is not thus handicapped.
http://www.van.ml.org/CircleMUD/    |                  -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST