From 5a714940f8f2d70710e1745115806df8ebab6a0c Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Tue, 20 May 2014 14:45:07 +0100 Subject: [PATCH] [Fix] Fixed minor memory leak. --- src/ai.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ai.c b/src/ai.c index 60bf261..4cd2e05 100644 --- a/src/ai.c +++ b/src/ai.c @@ -1161,10 +1161,13 @@ static int ai_getlandplanet(lua_State* L) { Planet** planets; int nplanets, i; LuaVector lv; - planets = malloc(sizeof(Planet*) * cur_system->nplanets); 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++) if(planet_hasService(cur_system->planets[i], PLANET_SERVICE_BASIC) && !areEnemies(cur_pilot->faction, cur_system->planets[i]->faction))