Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Vladaar, Yandex

Members: 1
Guests: 1
Stats
Files
Topics
Posts
Members
Newest Member
481
3,734
19,366
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] Memory leak in clean_ob...
Forum Rules | Mark all | Recent Posts

[Bug] Memory leak in clean_obj - not clearing mudprog pointers
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 5, 2005, 4:06 pm   Last edited May 11, 2005, 6:56 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Bug: Memory leak in clean_obj - not clearing mudprog pointers
Danger: Medium - Memory leak
Found by: Samson
Fixed by: Samson

---

handler.c, locate:

/*
 * clean out an object (index) (leave list pointers intact )	-Thoric
 */
void clean_obj( OBJ_INDEX_DATA * obj )
{
   AFFECT_DATA *paf;
   AFFECT_DATA *paf_next;
   EXTRA_DESCR_DATA *ed;
   EXTRA_DESCR_DATA *ed_next;

   STRFREE( obj->name );
   STRFREE( obj->short_descr );
   STRFREE( obj->description );
   STRFREE( obj->action_desc );
   obj->item_type = 0;
   xCLEAR_BITS( obj->extra_flags );
   obj->wear_flags = 0;
   obj->count = 0;
   obj->weight = 0;
   obj->cost = 0;
   obj->value[0] = 0;
   obj->value[1] = 0;
   obj->value[2] = 0;
   obj->value[3] = 0;
   for( paf = obj->first_affect; paf; paf = paf_next )
   {
      paf_next = paf->next;
      DISPOSE( paf );
      top_affect--;
   }
   obj->first_affect = NULL;
   obj->last_affect = NULL;
   for( ed = obj->first_extradesc; ed; ed = ed_next )
   {
      ed_next = ed->next;
      STRFREE( ed->description );
      STRFREE( ed->keyword );
      DISPOSE( ed );
      top_ed--;
   }
   obj->first_extradesc = NULL;
   obj->last_extradesc = NULL;
}


Replace with:

void clean_obj( OBJ_INDEX_DATA *obj )
{
  AFFECT_DATA *paf, *paf_next;
  EXTRA_DESCR_DATA *ed, *ed_next;
  MPROG_DATA *mprog, *mprog_next;

STRFREE( obj->name );
STRFREE( obj->short_descr );
  STRFREE( obj->description );
STRFREE( obj->action_desc );
obj->item_type = 0;
  xCLEAR_BITS( obj->extra_flags );
obj->wear_flags = 0;
obj->count = 0;
obj->weight = 0;
obj->cost = 0;
obj->value[0] = 0;
obj->value[1] = 0;
obj->value[2] = 0;
obj->value[3] = 0;
obj->value[4] = 0;
obj->value[5] = 0;
  for( paf = obj->first_affect; paf; paf = paf_next )
{
   paf_next    = paf->next;
   DISPOSE( paf );
   top_affect--;
}
obj->first_affect = NULL;
obj->last_affect = NULL;
  for( ed = obj->first_extradesc; ed; ed = ed_next )
{
   ed_next = ed->next;
     STRFREE( ed->description );
   STRFREE( ed->keyword     );
   DISPOSE( ed );
   top_ed--;
}
obj->first_extradesc = NULL;
obj->last_extradesc = NULL;
  for( mprog = obj->mudprogs; mprog; mprog = mprog_next )
       {
           mprog_next = mprog->next;
           STRFREE( mprog->arglist );
           STRFREE( mprog->comlist );
           DISPOSE( mprog );
       }
}


The function clean_obj is meant to do just that, clean the object index of any lingering data. This should have included the mudprog lists but didn't. Failure to clean these lists will result in a memory leak and will cause what should be a clean object to retain any programs it once had.
       
Pages:<< prev 1 next >>