Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Bevendorff <janek@jbev.net>2018-01-07 02:30:18 +0300
committerJonathan White <support@dmapps.us>2018-01-13 22:24:58 +0300
commit72a1c65d003789fa9ad6330b8c6e6fe3ccb5eb42 (patch)
treecbf1bc76650242eefd72aceea7a63d82e09662b1 /src/format
parentccfd7a065c821b3075144f497ddff6b4c80598f1 (diff)
Fix memory leaks in tests
Diffstat (limited to 'src/format')
-rw-r--r--src/format/Kdbx3XmlReader.cpp2
-rw-r--r--src/format/Kdbx4Writer.cpp32
2 files changed, 17 insertions, 17 deletions
diff --git a/src/format/Kdbx3XmlReader.cpp b/src/format/Kdbx3XmlReader.cpp
index 18dd0914d..fdc9cb416 100644
--- a/src/format/Kdbx3XmlReader.cpp
+++ b/src/format/Kdbx3XmlReader.cpp
@@ -1031,7 +1031,7 @@ Group* Kdbx3XmlReader::getGroup(const Uuid& uuid)
if (m_groups.contains(uuid)) {
return m_groups.value(uuid);
} else {
- Group* group = new Group();
+ auto group = new Group();
group->setUpdateTimeinfo(false);
group->setUuid(uuid);
group->setParent(m_tmpParent);
diff --git a/src/format/Kdbx4Writer.cpp b/src/format/Kdbx4Writer.cpp
index 8b503c73a..fbd590563 100644
--- a/src/format/Kdbx4Writer.cpp
+++ b/src/format/Kdbx4Writer.cpp
@@ -114,24 +114,25 @@ bool Kdbx4Writer::writeDatabase(QIODevice* device, Database* db)
CHECK_RETURN_FALSE(writeData(headerData));
QByteArray headerHash = CryptoHash::hash(headerData, CryptoHash::Sha256);
- QScopedPointer<QIODevice> firstLayer, secondLayer;
-
QByteArray hmacKey = KeePass2::hmacKey(masterSeed, db->transformedMasterKey());
QByteArray headerHmac = CryptoHash::hmac(headerData, HmacBlockStream::getHmacKey(UINT64_MAX, hmacKey),
CryptoHash::Sha256);
CHECK_RETURN_FALSE(writeData(headerHash));
CHECK_RETURN_FALSE(writeData(headerHmac));
- HmacBlockStream* hmacStream = new HmacBlockStream(device, hmacKey);
- if (!hmacStream->open(QIODevice::WriteOnly)) {
- raiseError(hmacStream->errorString());
+ QScopedPointer<HmacBlockStream> hmacBlockStream;
+ QScopedPointer<SymmetricCipherStream> cipherStream;
+
+ hmacBlockStream.reset(new HmacBlockStream(device, hmacKey));
+ if (!hmacBlockStream->open(QIODevice::WriteOnly)) {
+ raiseError(hmacBlockStream->errorString());
return false;
}
- firstLayer.reset(static_cast<QIODevice*>(hmacStream));
- SymmetricCipherStream* cipherStream = new SymmetricCipherStream(hmacStream, algo,
- SymmetricCipher::algorithmMode(algo),
- SymmetricCipher::Encrypt);
+ cipherStream.reset(new SymmetricCipherStream(hmacBlockStream.data(), algo,
+ SymmetricCipher::algorithmMode(algo),
+ SymmetricCipher::Encrypt));
+
if (!cipherStream->init(finalKey, encryptionIV)) {
raiseError(cipherStream->errorString());
return false;
@@ -140,13 +141,12 @@ bool Kdbx4Writer::writeDatabase(QIODevice* device, Database* db)
raiseError(cipherStream->errorString());
return false;
}
- secondLayer.reset(static_cast<QIODevice*>(cipherStream));
QScopedPointer<QtIOCompressor> ioCompressor;
if (db->compressionAlgo() == Database::CompressionNone) {
- m_device = secondLayer.data();
+ m_device = cipherStream.data();
} else {
- ioCompressor.reset(new QtIOCompressor(secondLayer.data()));
+ ioCompressor.reset(new QtIOCompressor(cipherStream.data()));
ioCompressor->setStreamFormat(QtIOCompressor::GzipFormat);
if (!ioCompressor->open(QIODevice::WriteOnly)) {
raiseError(ioCompressor->errorString());
@@ -191,12 +191,12 @@ bool Kdbx4Writer::writeDatabase(QIODevice* device, Database* db)
if (ioCompressor) {
ioCompressor->close();
}
- if (!secondLayer->reset()) {
- raiseError(secondLayer->errorString());
+ if (!cipherStream->reset()) {
+ raiseError(cipherStream->errorString());
return false;
}
- if (!firstLayer->reset()) {
- raiseError(firstLayer->errorString());
+ if (!hmacBlockStream->reset()) {
+ raiseError(hmacBlockStream->errorString());
return false;
}