From d0c4e7982226114fd0ccf8141ec69958b620088b Mon Sep 17 00:00:00 2001 From: Osyotr Date: Sun, 24 Dec 2023 18:31:07 +0300 Subject: [PATCH] Fix use of invalid iterator in Beam::Add `pop_back` invalidates `it` if `it == std::prev(m_entries.end())` Signed-off-by: Osyotr --- base/beam.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/beam.hpp b/base/beam.hpp index e771a72a14..cc633aadae 100644 --- a/base/beam.hpp +++ b/base/beam.hpp @@ -53,7 +53,15 @@ public: } if (m_entries.size() == m_capacity) + { + if (it == std::prev(m_entries.end())) + { + m_entries.back() = Entry(key, value); + return; + } + m_entries.pop_back(); + } m_entries.insert(it, Entry(key, value)); }