Login
User Name:

Password:



Register

Forgot your password?
Overland with Bitmaps
Jul 4, 2025 11:57 pm
By Samson
void nanny_get_new_race -- comm.c
Mar 13, 2025 7:08 am
By Elwood
IPv6
Jan 25, 2025 10:45 pm
By Samson
mudstrlcpy and mudstrlcat
Jan 18, 2025 5:23 pm
By Samson
I3 and IMC
Jan 17, 2025 9:35 pm
By Samson
SWFotEFUSS 1.5.3
Author: Various
Submitted by: Samson
SWRFUSS 1.4.3
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.8
Author: Various
Submitted by: Samson
AFKMud 2.5.2
Author: AFKMud Team
Submitted by: Samson
SmaugFUSS 1.9.7
Author: Various
Submitted by: Samson
Users Online
Anthropic, Majestic-12, DotBot, Google, Amazonbot, Bing

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
507
3,812
19,727
601
PedroJooLu

» SmaugMuds » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] Crashes and memory leak...
Forum Rules | Mark all | Recent Posts

[Bug] Crashes and memory leaks in OLC functions
< Newer Topic :: Older Topic > AFKMud 1.77

Pages:<< prev 1 next >>
Post is unread #1 Sep 10, 2006 5:14 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,708
JoinedJan 1, 2002

 
Bug: Crashes and memory leaks in OLC functions
Danger: Critical - Crashes, memory leaks, and possible data corruption
Discovered in: AFKMud 1.77
Found by: Valcados
Fixed by: Valcados

---

db.c, delete_room

Locate:
   while( ( ch = room->first_person ) != NULL )
   {
      if( !IS_NPC( ch ) )
      {
         char_from_room( ch );
         if( !char_to_room( ch, limbo ) )
            log_printf( "char_to_room: %s:%s, line %d.", __FILE__, __FUNCTION__, __LINE__ );
      }
      else
         extract_char( ch, TRUE );
   }


Below that, add:
   for( ch = first_char; ch; ch = ch->next )
   {
      if( ch->was_in_room == room )
         ch->was_in_room = ch->in_room;
      if( ch->substate == SUB_ROOM_DESC && ch->pcdata->dest_buf == room )
      {
         send_to_char( "The room is no more.\r\n", ch );
         stop_editing( ch );
         ch->substate = SUB_NONE;
         ch->pcdata->dest_buf = NULL;
      }
      else if( ch->substate == SUB_ROOM_EXTRA && ch->pcdata->dest_buf )
      {
         for( ed = room->first_extradesc; ed; ed = ed->next )
         {
            if( ed == ch->pcdata->dest_buf )
            {
               send_to_char( "The room is no more.\r\n", ch );
               stop_editing( ch );
               ch->substate = SUB_NONE;
               ch->pcdata->dest_buf = NULL;
               break;
            }
         }
      }
   }


db.c, delete_obj

Locate:
   AFFECT_DATA *af;
   MPROG_DATA *mp;


Beloe that, add:
   CHAR_DATA *ch;


Locate:
   /*
    * Remove references to object index 
    */
   for( o = first_object; o; o = o_next )
   {
      o_next = o->next;
      if( o->pIndexData == obj )
         extract_obj( o );
   }


Below that, add:
   for( ch = first_char; ch; ch = ch->next )
   {
      if( ch->substate == SUB_OBJ_EXTRA && ch->pcdata->dest_buf )
      {
         for( ed = obj->first_extradesc; ed; ed = ed->next )
         {
            if( ed == ch->pcdata->dest_buf )
            {
               send_to_char( "You suddenly forget which object you were editing!\r\n", ch );
               stop_editing( ch );
               ch->substate = SUB_NONE;
               break;
            }
         }
      }
      else if( ch->substate == SUB_MPROG_EDIT && ch->pcdata->dest_buf )
      {
         for( mp = obj->mudprogs; mp; mp = mp->next )
         {
            if( mp == ch->pcdata->dest_buf )
            {
               send_to_char( "You suddenly forget which object you were working on.\r\n", ch );
               stop_editing( ch );
               ch->pcdata->dest_buf = NULL;
               ch->substate = SUB_NONE;
               break;
            }
         }
      }
   }


db.c, delete_mob

Locate:
   for( ch = first_char; ch; ch = ch_next )
   {
      ch_next = ch->next;
      if( ch->pIndexData == mob )
         extract_char( ch, TRUE );
   }


Change to:
   for( ch = first_char; ch; ch = ch_next )
   {
      ch_next = ch->next;

      if( ch->pIndexData == mob )
         extract_char( ch, TRUE );
      else if( ch->substate == SUB_MPROG_EDIT && ch->pcdata->dest_buf )
      {
         for( mp = mob->mudprogs; mp; mp = mp->next )
         {
            if( mp == ch->pcdata->dest_buf )
            {
               send_to_char( "Your victim has departed.\r\n", ch );
               stop_editing( ch );
               ch->pcdata->dest_buf = NULL;
               ch->substate = SUB_NONE;
               break;
            }
         }
      }
   }


OLC is a complicated beast and there are some pitfalls to being allowed to delete content online. The most serious of which is being in an edit buffer for an object or mob description when the target is deleted out from under someone by another immortal. The imm who just lost their target will not necessarily be aware of this and when exiting the buffer things are likely to crash. If they don't crash, then it's still possible that data will get corrupted elsewhere. This also does not take care of freeing up the now bogus editor data contents.

Pages:<< prev 1 next >>