Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] Re: (PR#6898) leaks in game_load / player_load
Home

[Freeciv-Dev] Re: (PR#6898) leaks in game_load / player_load

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bh@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6898) leaks in game_load / player_load
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Nov 2003 13:17:55 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6898 >

Benoit Hudson wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=6898 >
> 
> On Tue, Nov 18, 2003 at 12:40:49PM -0800, Mike Kaufman wrote:
> 
>><URL: http://rt.freeciv.org/Ticket/Display.html?id=6898 >
>>
>>On Tue, Nov 18, 2003 at 09:44:57AM -0800, Benoit Hudson wrote:
>>
>>><URL: http://rt.freeciv.org/Ticket/Display.html?id=6898 >
>>>
>>>game_load does allot_island_improvs and then calls player_load.  In
>>>turn, player_load does player_init.  Finally, player_init clobbers an
>>>array that allot_island_improvs allocated, resulting in a memory leak.
>>
>>hmm, that does seem bad. Can you think of a solution?
> 
> 
> Possibly player_init should fc_realloc instead of fc_malloc -- but then
> I'm worried that player_init might be called on an uninitialized struct
> Player in which case that could be very bad.

That was my thought as well.  But the player array is a *currently* a 
statically declared array, meaning all its pointers are initialized to NULL.

If this change is done, though, a comment should be added to the players 
array to alert anyone thinking to change it in future.

jason




[Prev in Thread] Current Thread [Next in Thread]