From 68b7e03e20915f71a66cda31c967ff514d3dbfd9 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:22:35 +0200 Subject: [PATCH] Protect `WriterHistory::remove_change_and_reuse` (#5115) (#5120) Signed-off-by: Juan Lopez Fernandez (cherry picked from commit 0d996bc3eaf73a59d3f197207f80bc44b7512aff) Co-authored-by: juanlofer-eprosima <88179026+juanlofer-eprosima@users.noreply.github.com> --- src/cpp/rtps/history/WriterHistory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpp/rtps/history/WriterHistory.cpp b/src/cpp/rtps/history/WriterHistory.cpp index 1553d35881a..28fdf946986 100644 --- a/src/cpp/rtps/history/WriterHistory.cpp +++ b/src/cpp/rtps/history/WriterHistory.cpp @@ -254,6 +254,8 @@ CacheChange_t* WriterHistory::remove_change_and_reuse( return nullptr; } + std::lock_guard guard(*mp_mutex); + // Create a temporary reference change associated to the sequence number CacheChange_t ch; ch.sequenceNumber = sequence_number;