Skip to content

Commit 693c83f

Browse files
authored
replay: fix dangling pointers in logging calls (#36738)
fix dangling pointers in logging calls
1 parent 8ffe3f2 commit 693c83f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tools/replay/replay.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ void Replay::setupServices(const std::vector<std::string> &allow, const std::vec
3131
sockets_.resize(event_schema.getUnionFields().size(), nullptr);
3232

3333
std::vector<const char *> active_services;
34+
active_services.reserve(services.size());
35+
3436
for (const auto &[name, _] : services) {
3537
bool is_blocked = std::find(block.begin(), block.end(), name) != block.end();
3638
bool is_allowed = allow.empty() || std::find(allow.begin(), allow.end(), name) != allow.end();
@@ -40,7 +42,9 @@ void Replay::setupServices(const std::vector<std::string> &allow, const std::vec
4042
active_services.push_back(name.c_str());
4143
}
4244
}
43-
rInfo("active services: %s", join(active_services, ", ").c_str());
45+
46+
std::string services_str = join(active_services, ", ");
47+
rInfo("active services: %s", services_str.c_str());
4448
if (!sm_) {
4549
pm_ = std::make_unique<PubMaster>(active_services);
4650
}

tools/replay/seg_mgr.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ bool SegmentManager::mergeSegments(const SegmentMap::iterator &begin, const Segm
9191
auto &merged_events = merged_event_data->events;
9292
merged_events.reserve(total_event_count);
9393

94-
rDebug("merging segments: %s", join(segments_to_merge, ", ").c_str());
94+
std::string segments_str = join(segments_to_merge, ", ");
95+
rDebug("merging segments: %s", segments_str.c_str());
9596
for (int n : segments_to_merge) {
9697
const auto &events = segments_.at(n)->log->events;
9798
if (events.empty()) continue;

0 commit comments

Comments
 (0)