summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2022-03-08 18:49:39 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-21 23:01:32 +0000
commitc46d18eb30b8fab62cc9d95cac947e1a23cf7447 (patch)
tree7d713d70c65782a57566a63ddfd3998912230bcd
parentfebc387f120c7c9dcd72c0a9689d847af0f108ea (diff)
downloadqtapplicationmanager-c46d18eb30b8fab62cc9d95cac947e1a23cf7447.tar.gz
Fix memory leaks in the auto tests
Found by using the Linux/gcc/ASAN leak checker. Change-Id: Id9e2aae8c79b0d1ae71f90e7fbbb876ff9076def Reviewed-by: Bernd Weimer <bernd.weimer@qt.io> (cherry picked from commit 4178fd06ebf3af17019b29d7010a2b81571bec91) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/runtime/tst_runtime.cpp8
-rw-r--r--tests/auto/yaml/tst_yaml.cpp9
2 files changed, 13 insertions, 4 deletions
diff --git a/tests/auto/runtime/tst_runtime.cpp b/tests/auto/runtime/tst_runtime.cpp
index 4daf5b98..85f4e5fa 100644
--- a/tests/auto/runtime/tst_runtime.cpp
+++ b/tests/auto/runtime/tst_runtime.cpp
@@ -137,11 +137,13 @@ void tst_Runtime::factory()
temp.close();
QScopedPointer<Application> a;
+ QScopedPointer<PackageInfo> pi;
+ QScopedPointer<Package> p;
try {
- PackageInfo *pi = PackageInfo::fromManifest(temp.fileName());
+ pi.reset(PackageInfo::fromManifest(temp.fileName()));
QVERIFY(pi);
- Package *p = new Package(pi);
- a.reset(new Application(pi->applications().constFirst(), p));
+ p.reset(new Package(pi.get()));
+ a.reset(new Application(pi->applications().constFirst(), p.get()));
} catch (const Exception &e) {
QVERIFY2(false, qPrintable(e.errorString()));
}
diff --git a/tests/auto/yaml/tst_yaml.cpp b/tests/auto/yaml/tst_yaml.cpp
index b13a88a3..b189142d 100644
--- a/tests/auto/yaml/tst_yaml.cpp
+++ b/tests/auto/yaml/tst_yaml.cpp
@@ -311,6 +311,9 @@ void tst_Yaml::cache()
QVERIFY(ct2);
QCOMPARE(ct2->name, qSL("cache2"));
QCOMPARE(ct2->file, qSL(":/data/cache2.yaml"));
+
+ delete ct1;
+ delete ct2;
} catch (const Exception &e) {
QVERIFY2(false, e.what());
}
@@ -364,6 +367,8 @@ void tst_Yaml::mergedCache()
QVERIFY(ct);
QCOMPARE(ct->name, QFileInfo(files.last()).baseName());
QCOMPARE(ct->file, files.join(qSL(",")));
+
+ delete ct;
} catch (const Exception &e) {
QVERIFY2(false, e.what());
}
@@ -385,7 +390,9 @@ void tst_Yaml::mergedCache()
QTest::ignoreMessage(QtWarningMsg, "Failed to read Cache: cached file checksums do not match");
brokenCache.parse();
QVERIFY(brokenCache.parseReadFromCache());
- QCOMPARE(brokenCache.takeMergedResult()->value, qSL("foobar"));
+ CacheTest *ct = brokenCache.takeMergedResult();
+ QCOMPARE(ct->value, qSL("foobar"));
+ delete ct;
}
class YamlRunnable : public QRunnable