Avoid potentially using unit IDs that are no longer valid
Resolves #6603 (crash with musl implementation of libc)
(cherry picked from commit aa6b5b493d
)
This commit is contained in:
parent
6a37f9f9a1
commit
1fb6ca626e
2 changed files with 4 additions and 1 deletions
|
@ -49,6 +49,7 @@
|
|||
* Fixed a crash with "laststrike" (firststrike given to the opponent) weapon specials (issue #6575).
|
||||
* Fixed a crash with locally-edited add-ons that had neither `_server.pbl` nor `_info.cfg` (issue #6389).
|
||||
* Added more unit tests for weapon specials.
|
||||
* Resolve crash on systems using musl implementation of libc (issue #6603)
|
||||
|
||||
## Version 1.16.2
|
||||
### Campaigns
|
||||
|
|
|
@ -56,8 +56,10 @@ unit_const_ptr recall_list_manager::find_if_matches_id(const std::string &unit_i
|
|||
*/
|
||||
void recall_list_manager::erase_if_matches_id(const std::string &unit_id)
|
||||
{
|
||||
// using unit_id as reference has potential to cause a crash if the underlying unit becomes invald
|
||||
// https://github.com/wesnoth/wesnoth/issues/6603
|
||||
recall_list_.erase(std::remove_if(recall_list_.begin(), recall_list_.end(),
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id() == unit_id; }),
|
||||
[unit_id](const unit_ptr & ptr) { return ptr->id() == unit_id; }),
|
||||
recall_list_.end());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue