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
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2019-03-11 11:42:03 +0000
+++ src/logic/map.cc 2019-03-24 13:16:37 +0000
@@ -411,7 +411,6 @@
411 background_ = std::string();411 background_ = std::string();
412412
413 objectives_.clear();413 objectives_.clear();
414
415 port_spaces_.clear();414 port_spaces_.clear();
416 allows_seafaring_ = false;415 allows_seafaring_ = false;
417416
@@ -2175,12 +2174,16 @@
2175}2174}
21762175
2177void Map::cleanup_port_spaces(const World& world) {2176void Map::cleanup_port_spaces(const World& world) {
2177 // Temporary set to avoid problems with concurrent container operations
2178 PortSpacesSet clean_me_up;
2178 for (const Coords& c : get_port_spaces()) {2179 for (const Coords& c : get_port_spaces()) {
2179 if (!is_port_space_allowed(world, get_fcoords(c))) {2180 if (!is_port_space_allowed(world, get_fcoords(c))) {
2180 set_port_space(world, c, false);2181 clean_me_up.insert(c);
2181 continue;
2182 }2182 }
2183 }2183 }
2184 for (const Coords& c : clean_me_up) {
2185 set_port_space(world, c, false);
2186 }
2184 recalculate_allows_seafaring();2187 recalculate_allows_seafaring();
2185}2188}
21862189

Subscribers

People subscribed via source and target branches

to status/vote changes: