From d33957af6cd2425c418de9ef786265c83b400131 Mon Sep 17 00:00:00 2001 From: Tomasz Golinski Date: Mon, 18 Jul 2022 19:00:48 +0200 Subject: [PATCH] Fix segfault in traildb by fixing shallow copy of PowertrailDB --- powertrail.cpp | 2 +- powertrail.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/powertrail.cpp b/powertrail.cpp index e64a7d4..596c571 100644 --- a/powertrail.cpp +++ b/powertrail.cpp @@ -143,7 +143,7 @@ void PowertrailDB::save_to_json(std::string file) { 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& c : t.second.caches) { data.insert({ c, t.second.number }); diff --git a/powertrail.h b/powertrail.h index 8c63e8d..bee01b9 100644 --- a/powertrail.h +++ b/powertrail.h @@ -53,7 +53,7 @@ class Caches_in_Powertrails { public: std::unordered_map data; - Caches_in_Powertrails(PowertrailDB db); + Caches_in_Powertrails(const PowertrailDB& db); Caches_in_Powertrails(){}; void read_from_json(std::string file);