summaryrefslogtreecommitdiffstats
path: root/common/index.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-08 10:11:20 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-08 10:11:20 +0200
commit57e662cadc1f04ce58e34bc08907d7fc75eeb176 (patch)
tree59b37bbd2a55b2d39295559ef157a0350c82dcdb /common/index.cpp
parent373b444d83ad217574a738383fde9f9b36d89f7d (diff)
downloadsink-57e662cadc1f04ce58e34bc08907d7fc75eeb176.tar.gz
sink-57e662cadc1f04ce58e34bc08907d7fc75eeb176.zip
Avoid dangling references
Diffstat (limited to 'common/index.cpp')
-rw-r--r--common/index.cpp3
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
44QByteArray Index::lookup(const QByteArray &key) 44QByteArray 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}