Skip to content

Commit

Permalink
Avoid potentially using unit IDs that are no longer valid
Browse files Browse the repository at this point in the history
Resolves #6603 (crash with musl implementation of libc)
  • Loading branch information
Wedge009 committed Apr 10, 2022
1 parent 65d8c20 commit e610d6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
### WML Engine
### Miscellaneous and Bug Fixes
* Reduced the size of Isar's Cross map background images.
* Resolve crash on systems using musl implementation of libc (issue #6603)

## Version 1.17.2
### Add-ons client
Expand Down
4 changes: 3 additions & 1 deletion src/recall_list_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit e610d6b

Please sign in to comment.