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, Google

Members: 0
Guests: 4
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 » Codebases » SWR FUSS » string not freed in fread_pla...
Forum Rules | Mark all | Recent Posts

string not freed in fread_planet
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Feb 5, 2009, 2:55 pm   Last edited Feb 5, 2009, 3:02 pm by Samsa
Go to the top of the page
Go to the bottom of the page

Samsa
Fledgling
GroupMembers
Posts15
JoinedAug 29, 2008

In clans.c, fread_planet lines 399-411:

case 'S':
            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;
            }
            break;


It seems that
planet->starsystem = starsystem_from_name( fread_string( fp ) );
read a string, but it's never freed.

The same problem appears a few lines before:

case 'G':
	    if ( !str_cmp( word, "GovernedBy" ) )
	    {
	     	planet->governed_by = get_clan ( fread_string(fp) );
                fMatch = TRUE;
	    }
	    break;
       
Post is unread #2 Feb 5, 2009, 3:42 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Yep, certainly looks like those should be redone to read the string into a temp variable and assign the starsystem using that instead. Calling fread_string in this manner allocates it in the hash but as you say it's never released.
       
Post is unread #3 Feb 8, 2009, 5:23 am
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Not sure if you have the function, but if you have fread_flagstring, you can replace fread_string with fread_flagstring, then you wouldn't have to worry about allocating/freeing a temporary variable for the starsystem name.
       
Pages:<< prev 1 next >>