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;