Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Yesterday, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Sogou, DotBot, Yahoo!, Bing

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SWR FUSS Bugfix List » [Bug] Memory Leaks in fread_p...
Forum Rules | Mark all | Recent Posts

[Bug] Memory Leaks in fread_planet.
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Feb 4, 2010, 10:04 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Bug: Memory Leaks while reading GovernedBy and Starsystem of planets.
Danger: High - Memory Leaks are BAD.
Found by: Caius
Fixed by: Kayle and Caius

---

clans.c, fread_planet

Find:
         case 'G':
            if( !str_cmp( word, "GovernedBy" ) )
            {
               planet->governed_by = get_clan( fread_string( fp ) );
               fMatch = TRUE;
            }
            break;


Replace with:
         case 'G':
            if( !str_cmp( word, "GovernedBy" ) )
            {
               const char *clan_name = fread_string( fp );
               planet->governed_by = get_clan( clan_name );
               fMatch = TRUE;
               STRFREE( clan_name );
            }
            break;



Find:
            if( !str_cmp( word, "Starsystem" ) )
            {
               planet->starsystem = starsystem_from_name( fread_string( fp ) );
               if( planet->starsystem )
               {
                  SPACE_DATA *starsystem = planet->starsystem;

                  LINK( planet, starsystem->first_planet, starsystem->last_planet, next_in_system, prev_in_system );
               }
               fMatch = TRUE;
            }


Replace with:
            if( !str_cmp( word, "Starsystem" ) )
            {
               const char *starsystem_name = fread_string( fp );
               planet->starsystem = starsystem_from_name( starsystem_name );
               if( planet->starsystem )
               {
                  SPACE_DATA *starsystem = planet->starsystem;

                  LINK( planet, starsystem->first_planet, starsystem->last_planet, next_in_system, prev_in_system );
               }
               fMatch = TRUE;
               STRFREE( starsystem_name );
            }


I think I said this already, but.. Memory Leaks are BAD. Bad for business. Bad for.. just Bad. See, fread_string calls STRALLOC. Which allocates memory. But said memory was never being freed. Thus.. memory leak. So you do what I did and poof. No more leak.

       
Pages:<< prev 1 next >>