Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
AhrefsBot

Members: 0
Guests: 18
Stats
Files
Topics
Posts
Members
Newest Member
489
3,793
19,649
597
Aileenutz

Today's Birthdays
There are no member birthdays today.
» 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,685
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 >>