Plug memory leak in fire command

add_to_fired_queue() adds a defender at most once.  It neglects to
free the defender flist nodes it doesn't add.  Broken since option
MULTIFIRE appeared in Chainsaw.
This commit is contained in:
Markus Armbruster 2008-03-13 20:06:13 +01:00
parent 7ba662567f
commit 3c7ea15195

View file

@ -902,11 +902,12 @@ add_to_fired_queue(struct emp_qelem *elem, struct emp_qelem *list)
/* Don't put them on the list if they're already there */
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
fp = (struct flist *)qp;
if (fp->type != targ_land && fp->uid == ep->uid)
return;
if (fp->type != targ_land
&& fp->x == ep->x && fp->y == ep->y)
if (fp->type == targ_land
? fp->x == ep->x && fp->y == ep->y
: fp->uid == ep->uid) {
free(ep);
return;
}
}
emp_insque(elem, list);
}