diff options
author | Ingo Klöcker <dev@ingo-kloecker.de> | 2023-01-31 09:10:57 +0100 |
---|---|---|
committer | Ingo Klöcker <dev@ingo-kloecker.de> | 2023-01-31 12:01:33 +0100 |
commit | 2b98585c89c1654aa736777eeb92ff79d5fdd72b (patch) | |
tree | a9e1b9b277bdbd35ae5adf089fe09b92f89a8d61 | |
parent | 5d07f8db7763d5cc48c7b27d5cc67d74fad77ea4 (diff) | |
download | gpgme-2b98585c89c1654aa736777eeb92ff79d5fdd72b.tar.gz |
qt,tests: Avoid leaking Context
* lang/qt/tests/t-import.cpp: Wrap Context*s in unique_ptr.
--
This fixes leaks found with -fsanitize=address.
-rw-r--r-- | lang/qt/tests/t-import.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lang/qt/tests/t-import.cpp b/lang/qt/tests/t-import.cpp index 2991cf3d..91d5bcbd 100644 --- a/lang/qt/tests/t-import.cpp +++ b/lang/qt/tests/t-import.cpp @@ -48,6 +48,8 @@ #include <QTemporaryDir> #include <QTest> +#include <memory> + using namespace QGpgME; using namespace GpgME; @@ -111,7 +113,7 @@ private Q_SLOTS: QSignalSpy spy (this, SIGNAL(asyncDone())); QVERIFY(spy.wait()); - auto ctx = Context::createForProtocol(GpgME::OpenPGP); + auto ctx = std::unique_ptr<GpgME::Context>(Context::createForProtocol(GpgME::OpenPGP)); GpgME::Error err; const auto key = ctx->key(keyFpr, err, false); QVERIFY(!key.isNull()); @@ -155,7 +157,7 @@ private Q_SLOTS: QSignalSpy spy (this, SIGNAL(asyncDone())); QVERIFY(spy.wait()); - auto ctx = Context::createForProtocol(GpgME::OpenPGP); + auto ctx = std::unique_ptr<GpgME::Context>(Context::createForProtocol(GpgME::OpenPGP)); GpgME::Error err; const auto key = ctx->key(keyFpr, err, false); QVERIFY(!key.isNull()); @@ -194,7 +196,7 @@ private Q_SLOTS: QSignalSpy spy (this, SIGNAL(asyncDone())); QVERIFY(spy.wait()); - auto ctx = Context::createForProtocol(GpgME::OpenPGP); + auto ctx = std::unique_ptr<GpgME::Context>(Context::createForProtocol(GpgME::OpenPGP)); GpgME::Error err; const auto key = ctx->key(keyFpr, err, false); QVERIFY(!key.isNull()); |