diff options
Diffstat (limited to 'common/index.cpp')
-rw-r--r-- | common/index.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/common/index.cpp b/common/index.cpp index b5e9980..151f7af 100644 --- a/common/index.cpp +++ b/common/index.cpp | |||
@@ -44,6 +44,7 @@ void Index::lookup(const QByteArray &key, const std::function<void(const QByteAr | |||
44 | QByteArray Index::lookup(const QByteArray &key) | 44 | QByteArray Index::lookup(const QByteArray &key) |
45 | { | 45 | { |
46 | QByteArray result; | 46 | QByteArray result; |
47 | lookup(key, [&result](const QByteArray &value) { result = value; }, [this](const Index::Error &error) { Trace() << "Error while retrieving value" << error.message; }); | 47 | //We have to create a deep copy, otherwise the returned data may become invalid when the transaction ends. |
48 | lookup(key, [&result](const QByteArray &value) { result = QByteArray(value.constData(), value.size()); }, [this](const Index::Error &error) { Trace() << "Error while retrieving value" << error.message; }); | ||
48 | return result; | 49 | return result; |
49 | } | 50 | } |