From a27d7755d071aad42efc2aa4ea3899ba7b17f8bf Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Wed, 10 Aug 2016 12:05:32 +0200 Subject: [PATCH] Qt: Create TestPassphraseProvider on stack * lang/qt/tests/t-encrypt.cpp, lang/qt/tests/t-tofuinfo.cpp: Create TestPassphraseProvider on stack. -- Context does not delete the provider. This fixes ASAN errors. --- lang/qt/tests/t-encrypt.cpp | 8 +++++--- lang/qt/tests/t-tofuinfo.cpp | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lang/qt/tests/t-encrypt.cpp b/lang/qt/tests/t-encrypt.cpp index b0b6994c..c6fcaa21 100644 --- a/lang/qt/tests/t-encrypt.cpp +++ b/lang/qt/tests/t-encrypt.cpp @@ -71,7 +71,8 @@ private Q_SLOTS: /* Now decrypt */ auto ctx = Context::createForProtocol(OpenPGP); - ctx->setPassphraseProvider(new TestPassphraseProvider); + TestPassphraseProvider provider; + ctx->setPassphraseProvider(&provider); ctx->setPinentryMode(Context::PinentryLoopback); auto decJob = new QGpgMEDecryptJob(ctx); QByteArray plainText; @@ -84,7 +85,8 @@ private Q_SLOTS: void testSymmetricEncryptDecrypt() { auto ctx = Context::createForProtocol(OpenPGP); - ctx->setPassphraseProvider(new TestPassphraseProvider); + TestPassphraseProvider provider; + ctx->setPassphraseProvider(&provider); ctx->setPinentryMode(Context::PinentryLoopback); ctx->setArmor(true); ctx->setTextMode(true); @@ -99,7 +101,7 @@ private Q_SLOTS: killAgent(mDir.path()); auto ctx2 = Context::createForProtocol(OpenPGP); - ctx2->setPassphraseProvider(new TestPassphraseProvider); + ctx2->setPassphraseProvider(&provider); ctx2->setPinentryMode(Context::PinentryLoopback); auto decJob = new QGpgMEDecryptJob(ctx2); QByteArray plainText; diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp index 83310921..3072f0fc 100644 --- a/lang/qt/tests/t-tofuinfo.cpp +++ b/lang/qt/tests/t-tofuinfo.cpp @@ -73,7 +73,8 @@ class TofuInfoTest: public QGpgMETest void signAndVerify(const QString &what, const GpgME::Key &key, int expected) { Context *ctx = Context::createForProtocol(OpenPGP); - ctx->setPassphraseProvider(new TestPassphraseProvider); + TestPassphraseProvider provider; + ctx->setPassphraseProvider(&provider); ctx->setPinentryMode(Context::PinentryLoopback); auto *job = new QGpgMESignJob(ctx);