» SmaugMuds » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] Crashes and memory leak...
Pages:<< prev 1 next >>
#1 Sep 10, 2006 5:14 pm
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:
Below that, add:
db.c, delete_obj
Locate:
Beloe that, add:
Locate:
Below that, add:
db.c, delete_mob
Locate:
Change to:
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.
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 >>