]> git.pond.sub.org Git - empserver/commitdiff
fire: Plug memory leak when missile defense sinks firing ships
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 22 Jul 2016 04:46:15 +0000 (06:46 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:18 +0000 (20:09 +0200)
do_defdam() iterates over the list firing ships, applies return fire
to each, and frees its list element.  When it finds a ship that has
been sunk already, it skips it.  This also skips the free, leaking the
list element.  The leak goes back to flawed bug fix in Empire 2.

As far as I can see, missile defense is the only way a ship can be
sunk there.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/mfir.c

index 29d27cbad52bbd2f04c329cb06bd0f06bd7a63cf..2cf719289c4b8548e889441f85e6eba0dee21fc3 100644 (file)
@@ -427,6 +427,7 @@ multifire(void)
     else
        odds = 1.0;
     do_defdam(&fired, odds);
+    free_flist(&fired);
     return RET_OK;
 }
 
@@ -496,8 +497,6 @@ do_defdam(struct emp_qelem *list, double odds)
                wu(0, vict, "Return fire hit sector %s for %d damage.\n",
                   xyas(fp->x, fp->y, vict), dam);
        }
-       emp_remque(&fp->queue);
-       free(fp);
     }
 }