diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-03 21:31:53 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-03 21:31:53 +0200 |
commit | 00efa772f1b39db010e480bddb08c2e086d7b364 (patch) | |
tree | 5687131f54229bea1eebd6f0f824a12ffd228c12 /common/storage_common.cpp | |
parent | 9228b3ba170a0f68dbb432b2455c75d5fff21506 (diff) | |
download | sink-00efa772f1b39db010e480bddb08c2e086d7b364.tar.gz sink-00efa772f1b39db010e480bddb08c2e086d7b364.zip |
Dont pass around buffers to potentially invalid memory.
Once the transaction is done or some modification is executed
that memory is no longer valid. So we always copy.
Diffstat (limited to 'common/storage_common.cpp')
-rw-r--r-- | common/storage_common.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/storage_common.cpp b/common/storage_common.cpp index 81a38c7..f648c94 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp | |||
@@ -113,7 +113,7 @@ QByteArray DataStore::getUidFromRevision(const DataStore::Transaction &transacti | |||
113 | transaction.openDatabase("revisions") | 113 | transaction.openDatabase("revisions") |
114 | .scan(QByteArray::number(revision), | 114 | .scan(QByteArray::number(revision), |
115 | [&](const QByteArray &, const QByteArray &value) -> bool { | 115 | [&](const QByteArray &, const QByteArray &value) -> bool { |
116 | uid = value; | 116 | uid = QByteArray{value.constData(), value.size()}; |
117 | return false; | 117 | return false; |
118 | }, | 118 | }, |
119 | [revision](const Error &error) { SinkWarning() << "Couldn't find uid for revision: " << revision << error.message; }); | 119 | [revision](const Error &error) { SinkWarning() << "Couldn't find uid for revision: " << revision << error.message; }); |
@@ -126,7 +126,7 @@ QByteArray DataStore::getTypeFromRevision(const DataStore::Transaction &transact | |||
126 | transaction.openDatabase("revisionType") | 126 | transaction.openDatabase("revisionType") |
127 | .scan(QByteArray::number(revision), | 127 | .scan(QByteArray::number(revision), |
128 | [&](const QByteArray &, const QByteArray &value) -> bool { | 128 | [&](const QByteArray &, const QByteArray &value) -> bool { |
129 | type = value; | 129 | type = QByteArray{value.constData(), value.size()}; |
130 | return false; | 130 | return false; |
131 | }, | 131 | }, |
132 | [revision](const Error &error) { SinkWarning() << "Couldn't find type for revision " << revision; }); | 132 | [revision](const Error &error) { SinkWarning() << "Couldn't find type for revision " << revision; }); |