diff --git a/GpgMEWorker.cpp b/GpgMEWorker.cpp index 3f2efdf..1b53543 100644 --- a/GpgMEWorker.cpp +++ b/GpgMEWorker.cpp @@ -195,7 +195,12 @@ const Error GpgMEWorker::CreateKeyWithEngineDefaultAlgo(GpgME::Key& k, ? 0 : _CREATE_NOEXPIRE; KeyGenerationResult kgr = ctx->createKeyEx(uid.c_str(), "default", - 0, 0, k, flags); + 0, expires, k, flags); + delete ppp; + delete ctx; + if (kgr.error().code() == 0) + // Why is k not assigned the newly created key ?! + k = FindKey(kgr.fingerprint(), e, true); return kgr.error(); } @@ -222,10 +227,11 @@ const Error GpgMEWorker::CreateKey(GpgME::Key& k, KeyGenerationResult kgr = ctx->createKeyEx(uid.c_str(), algo, 0, expires, k, flags); - // Why is k not assigned the newly created key ?! - k = FindKey(kgr.fingerprint(), e, true); delete ppp; delete ctx; + if (kgr.error().code() == 0) + // Why is k not assigned the newly created key ?! + k = FindKey(kgr.fingerprint(), e, true); return kgr.error(); }