Re: [CODE] Switch bug (long)

From: Peter Ajamian (peter@pajamian.dhs.org)
Date: 06/17/01


Juliano Ravasi Ferraz wrote:
>
>       I have found a bug on CircleMUD 3.0 bpl18, envolving the
> close_socket() and the SWITCH command.  Here is a simple way
> to reproduce it (greetings and motds stripped):

This has been fixed in CVS, try the following patch:

$cvs diff -D 2001-05-18 -D 2001-05-19 comm.c
Index: comm.c
===================================================================
RCS file: /home/circledb/cvs/circle/src/comm.c,v
retrieving revision 1.88
retrieving revision 1.90
diff -u -p -r1.88 -r1.90
--- comm.c      2001/03/19 02:58:58     1.88
+++ comm.c      2001/05/18 17:39:31     1.90
@@ -1807,14 +1806,16 @@ void close_socket(struct descriptor_data
   }

   if (d->character) {
-    /*
-     * Plug memory leak, from Eric Green.
-     */
+    /* If we're switched, this resets the mobile taken. */
+    d->character->desc = NULL;
+
+    /* Plug memory leak, from Eric Green. */
     if (!IS_NPC(d->character) && 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) {
       struct char_data *link_challenged = d->original ? d->original :
d->character;

@@ -1823,7 +1824,6 @@ void close_socket(struct descriptor_data
       save_char(link_challenged, NOWHERE);
       sprintf(buf, "Closing link to: %s.", GET_NAME(link_challenged));
       mudlog(buf, NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(link_challenged)),
TRUE);
-      link_challenged->desc = NULL;
     } else {
       sprintf(buf, "Losing player: %s.",
              GET_NAME(d->character) ? GET_NAME(d->character) :
"<null>");

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST