Fix memory leaks in plane interception
Interception builds lists of planes that could intercept. Only list nodes for missiles were freed. Broken since BSD Empire 1.1. The fix frees interceptors that actually intercepted when ac_intercept() returns, and the interceptors that didn't when ac_encounter() returns. The latter introduces a small bug: it passes planes that didn't fly to pln_put(). pln_put() expects only planes that actually took off. Same bug exists in air defense missions. Luckily, it has no ill effects. To be fixed soon.
This commit is contained in:
parent
f7d5576675
commit
6fe12d0b7f
1 changed files with 8 additions and 5 deletions
|
@ -269,11 +269,8 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
|||
if (changed)
|
||||
writemap(player->cnum);
|
||||
/* Now, if the bomber and escort lists are empty, we are done */
|
||||
if (QEMPTY(bomb_list) && QEMPTY(esc_list)) {
|
||||
if (mission_flags & P_A)
|
||||
free_shiplist(&head);
|
||||
return;
|
||||
}
|
||||
if (QEMPTY(bomb_list) && QEMPTY(esc_list))
|
||||
goto out;
|
||||
|
||||
/* Something made it through */
|
||||
/* Go figure out if there are ships in this sector, and who's they are */
|
||||
|
@ -355,8 +352,13 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
|||
}
|
||||
}
|
||||
}
|
||||
out:
|
||||
if (mission_flags & P_A)
|
||||
free_shiplist(&head);
|
||||
for (cn = 1; cn < MAXNOC; cn++) {
|
||||
if (gotilist[cn])
|
||||
pln_put(&ilist[cn]);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -504,6 +506,7 @@ ac_intercept(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
|||
ac_airtoair(bomb_list, &int_list);
|
||||
PR(plane_owner, "\n");
|
||||
PR(def_own, "\n");
|
||||
pln_put(&int_list);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue