widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #16366
[Merge] lp:~widelands-dev/widelands/bug-1819311-port-spaces-heap-use-after-free into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1819311-port-spaces-heap-use-after-free into lp:widelands.
Commit message:
Use temporary container in cleanup_port_spaces to prevent invalid iterators.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1819311 in widelands: "heap-use-after-free cleanup_port_spaces"
https://bugs.launchpad.net/widelands/+bug/1819311
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1819311-port-spaces-heap-use-after-free/+merge/365004
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1819311-port-spaces-heap-use-after-free into lp:widelands.
=== 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:14:51 +0000
@@ -411,7 +411,6 @@
background_ = std::string();
objectives_.clear();
-
port_spaces_.clear();
allows_seafaring_ = false;
@@ -522,7 +521,6 @@
new_port_spaces.insert(temp);
}
port_spaces_ = new_port_spaces;
- log("Map origin was shifted by (%d, %d)\n", new_origin.x, new_origin.y);
}
/*
@@ -2175,12 +2173,16 @@
}
void Map::cleanup_port_spaces(const World& world) {
+ // Temporary set to avoid problems with concurrent container operations
+ PortSpacesSet clean_me_up;
for (const Coords& c : get_port_spaces()) {
if (!is_port_space_allowed(world, get_fcoords(c))) {
- set_port_space(world, c, false);
- continue;
+ clean_me_up.insert(c);
}
}
+ for (const Coords& c : clean_me_up) {
+ set_port_space(world, c, false);
+ }
recalculate_allows_seafaring();
}
=== modified file 'src/logic/map.h'
--- src/logic/map.h 2019-03-11 11:42:03 +0000
+++ src/logic/map.h 2019-03-24 13:14:51 +0000
@@ -28,6 +28,7 @@
#include <vector>
#include "base/i18n.h"
+#include "base/log.h"
#include "economy/itransport_cost_calculator.h"
#include "logic/description_maintainer.h"
#include "logic/field.h"
Follow ups