[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]
<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
|
|