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, Yandex, DotBot, Sogou

Members: 0
Guests: 7
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_ro...
Forum Rules | Mark all | Recent Posts

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

Pages:<< prev 1 next >>
Post is unread #1 Mar 5, 2005, 4:07 pm   Last edited May 11, 2005, 6:58 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_room - not clearing mudprog pointers
Danger: Medium - Memory leak
Found by: Samson
Fixed by: Samson

---

handler.c, locate:

/*
 * clean out a room (leave list pointers intact )  -Thoric
 */
void clean_room( ROOM_INDEX_DATA * room )
{
   EXTRA_DESCR_DATA *ed, *ed_next;
   EXIT_DATA *pexit, *pexit_next;

   STRFREE( room->description );
   STRFREE( room->name );
   for( ed = room->first_extradesc; ed; ed = ed_next )
   {
      ed_next = ed->next;
      STRFREE( ed->description );
      STRFREE( ed->keyword );
      DISPOSE( ed );
      top_ed--;
   }
   room->first_extradesc = NULL;
   room->last_extradesc = NULL;
   for( pexit = room->first_exit; pexit; pexit = pexit_next )
   {
      pexit_next = pexit->next;
      STRFREE( pexit->keyword );
      STRFREE( pexit->description );
      DISPOSE( pexit );
      top_exit--;
   }
   room->first_exit = NULL;
   room->last_exit = NULL;
   room->room_flags = 0;
   room->sector_type = 0;
   room->light = 0;
}


Replace with:

void clean_room( ROOM_INDEX_DATA *room )
{
  EXTRA_DESCR_DATA     *ed, *ed_next;
  EXIT_DATA            *pexit, *pexit_next;
  MPROG_DATA *mprog, *mprog_next;

  STRFREE( room->description );
  STRFREE( room->name );
  for( mprog = room->mudprogs; mprog; mprog = mprog_next )
       {
           mprog_next = mprog->next;
           STRFREE( mprog->arglist );
           STRFREE( mprog->comlist );
           DISPOSE( mprog );
       }
  for ( ed = room->first_extradesc; ed; ed = ed_next )
  {
       ed_next = ed->next;
       STRFREE( ed->description );
       STRFREE( ed->keyword );
       DISPOSE( ed );
       top_ed--;
  }
  room->first_extradesc        = NULL;
  room->last_extradesc         = NULL;
  for ( pexit = room->first_exit; pexit; pexit = pexit_next )
  {
       pexit_next = pexit->next;
     extract_exit( room, pexit );
       top_exit--;
  }
  room->first_exit = NULL;
  room->last_exit = NULL;
  room->room_flags = 0;
  room->sector_type = 0;
  room->light = 0;
}


The function clean_room is meant to do just that, clean the room 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 room to retain any programs it once had.
       
Pages:<< prev 1 next >>