Merge lp:~widelands-dev/widelands/bug-1819311-port-spaces-heap-use-after-free into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 9028
Proposed branch: lp:~widelands-dev/widelands/bug-1819311-port-spaces-heap-use-after-free
Merge into: lp:widelands
Diff against target: 29 lines (+6/-3)
1 file modified
src/logic/map.cc (+6/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1819311-port-spaces-heap-use-after-free
Reviewer Review Type Date Requested Status
Klaus Halfmann compile, review, test Approve
Review via email: mp+365004@code.launchpad.net

Commit message

Use temporary container in cleanup_port_spaces to prevent invalid iterators.

To post a comment you must log in.
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Fixed that bug, lets have it.

@bunnybot merge

review: Approve (compile, review, test)
Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for the review :)

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4637. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/510593332.
Appveyor build 4424. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1819311_port_spaces_heap_use_after_free-4424.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/map.cc'
2--- src/logic/map.cc 2019-03-11 11:42:03 +0000
3+++ src/logic/map.cc 2019-03-24 13:16:37 +0000
4@@ -411,7 +411,6 @@
5 background_ = std::string();
6
7 objectives_.clear();
8-
9 port_spaces_.clear();
10 allows_seafaring_ = false;
11
12@@ -2175,12 +2174,16 @@
13 }
14
15 void Map::cleanup_port_spaces(const World& world) {
16+ // Temporary set to avoid problems with concurrent container operations
17+ PortSpacesSet clean_me_up;
18 for (const Coords& c : get_port_spaces()) {
19 if (!is_port_space_allowed(world, get_fcoords(c))) {
20- set_port_space(world, c, false);
21- continue;
22+ clean_me_up.insert(c);
23 }
24 }
25+ for (const Coords& c : clean_me_up) {
26+ set_port_space(world, c, false);
27+ }
28 recalculate_allows_seafaring();
29 }
30

Subscribers

People subscribed via source and target branches

to status/vote changes: