diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index eb222078b5e..50a58d5fe03 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -370,6 +370,8 @@ void CDBIterator::SeekImpl(std::span key) std::span CDBIterator::GetKeyImpl() const { + // The returned span borrows from the current iterator entry and is only + // valid until the iterator is advanced. return MakeByteSpan(m_impl_iter->iter->key()); } diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 2eee6c1c023..75ac5fdb05b 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -153,7 +153,7 @@ public: template bool GetKey(K& key) { try { - DataStream ssKey{GetKeyImpl()}; + SpanReader ssKey{GetKeyImpl()}; ssKey >> key; } catch (const std::exception&) { return false;