[Fix] Fixed minor memory leak.
This commit is contained in:
parent
5429ed970d
commit
5a714940f8
5
src/ai.c
5
src/ai.c
@ -1161,10 +1161,13 @@ static int ai_getlandplanet(lua_State* L) {
|
|||||||
Planet** planets;
|
Planet** planets;
|
||||||
int nplanets, i;
|
int nplanets, i;
|
||||||
LuaVector lv;
|
LuaVector lv;
|
||||||
planets = malloc(sizeof(Planet*) * cur_system->nplanets);
|
|
||||||
|
|
||||||
if(cur_system->nplanets == 0) return 0; /* No planets. */
|
if(cur_system->nplanets == 0) return 0; /* No planets. */
|
||||||
|
|
||||||
|
/* Allocate memory. */
|
||||||
|
planets = malloc(sizeof(Planet*) * cur_system->nplanets);
|
||||||
|
|
||||||
|
/* Copy friendly planets. */
|
||||||
for(nplanets = 0, i = 0; i < cur_system->nplanets; i++)
|
for(nplanets = 0, i = 0; i < cur_system->nplanets; i++)
|
||||||
if(planet_hasService(cur_system->planets[i], PLANET_SERVICE_BASIC) &&
|
if(planet_hasService(cur_system->planets[i], PLANET_SERVICE_BASIC) &&
|
||||||
!areEnemies(cur_pilot->faction, cur_system->planets[i]->faction))
|
!areEnemies(cur_pilot->faction, cur_system->planets[i]->faction))
|
||||||
|
Loading…
Reference in New Issue
Block a user