Fix segfault in traildb by fixing shallow copy of PowertrailDB

master
Tomasz Golinski 2022-07-18 19:00:48 +02:00
rodzic add9b37d2a
commit d33957af6c
2 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -143,7 +143,7 @@ void PowertrailDB::save_to_json(std::string file) {
datafile << j; datafile << j;
}; };
Caches_in_Powertrails::Caches_in_Powertrails(PowertrailDB db) { Caches_in_Powertrails::Caches_in_Powertrails(const PowertrailDB& db) {
for (auto& t : db.data) { for (auto& t : db.data) {
for (auto& c : t.second.caches) { for (auto& c : t.second.caches) {
data.insert({ c, t.second.number }); data.insert({ c, t.second.number });

Wyświetl plik

@ -53,7 +53,7 @@ class Caches_in_Powertrails {
public: public:
std::unordered_map<std::string, int> data; std::unordered_map<std::string, int> data;
Caches_in_Powertrails(PowertrailDB db); Caches_in_Powertrails(const PowertrailDB& db);
Caches_in_Powertrails(){}; Caches_in_Powertrails(){};
void read_from_json(std::string file); void read_from_json(std::string file);