Fix problems with memory ownership in message filters
The channel names and types from log replayer were not copied
to log reader because it was defined as string_view. Changing
the type to string resolved that for now.
Change-Id: If0e8668de5b9d51832fe8eec9e0681168c2c443e
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/logging/log_reader.cc b/aos/events/logging/log_reader.cc
index be49393..36c8e8a 100644
--- a/aos/events/logging/log_reader.cc
+++ b/aos/events/logging/log_reader.cc
@@ -1333,7 +1333,7 @@
RemapConflict conflict_handling) {
if (replay_channels_ != nullptr) {
CHECK(std::find(replay_channels_->begin(), replay_channels_->end(),
- std::make_pair(name, type)) != replay_channels_->end())
+ std::make_pair(std::string{name}, std::string{type})) != replay_channels_->end())
<< "Attempted to remap channel " << name << " " << type
<< " which is not included in the replay channels passed to LogReader.";
}
diff --git a/aos/events/logging/log_reader.h b/aos/events/logging/log_reader.h
index f56f6fa..d4936f1 100644
--- a/aos/events/logging/log_reader.h
+++ b/aos/events/logging/log_reader.h
@@ -33,7 +33,7 @@
// Vector of pair of name and type of the channel
using ReplayChannels =
- std::vector<std::pair<std::string_view, std::string_view>>;
+ std::vector<std::pair<std::string, std::string>>;
// Vector of channel indices
using ReplayChannelIndices = std::vector<size_t>;
diff --git a/aos/events/logging/log_replayer.cc b/aos/events/logging/log_replayer.cc
index 9d2e30d..c91464c 100644
--- a/aos/events/logging/log_replayer.cc
+++ b/aos/events/logging/log_replayer.cc
@@ -87,7 +87,7 @@
? std::nullopt
: std::make_optional(aos::JsonToFlatbuffer<ReplayConfig>(
aos::util::ReadFileToStringOrDie(FLAGS_replay_config.data())));
- std::vector<std::pair<std::string_view, std::string_view>> message_filter;
+ std::vector<std::pair<std::string, std::string>> message_filter;
if (FLAGS_skip_sender_channels && replay_config.has_value()) {
CHECK(replay_config.value().message().has_active_nodes());
std::vector<const Node *> active_nodes;