Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Fix crash on keygen error

If we have an error result's fingerprint is null. Working
with this could lead to crashes. Now we guard against this.

GnuPG-Bug-Id: 3577
parent 09a7645e
......@@ -866,7 +866,7 @@ private Q_SLOTS:
void slotResult(const GpgME::KeyGenerationResult &result, const QByteArray &request, const QString &auditLog)
if (result.error().code()) {
if (result.error().code() || !result.fingerprint()) {
setField(QStringLiteral("error"), result.error().isCanceled()
? i18n("Operation canceled.")
: i18n("Could not create key pair: %1",
......@@ -894,16 +894,22 @@ private Q_SLOTS:
// Ensure that we have the key in the keycache
if (pgp()) {
if (pgp() && !result.error().code() && result.fingerprint()) {
auto ctx = Context::createForProtocol(OpenPGP);
if (ctx) {
// Check is pretty useless something very buggy in that case.
Error e;
KeyCache::mutableInstance()->insert(ctx->key(result.fingerprint(), e, true));
const auto key = ctx->key(result.fingerprint(), e, true);
if (!key.isNull()) {
} else {
qCDebug(KLEOPATRA_LOG) << "Failed to find newly generated key.";
delete ctx;
setField(QStringLiteral("fingerprint"), QString::fromLatin1(result.fingerprint()));
setField(QStringLiteral("fingerprint"), result.fingerprint() ?
QString::fromLatin1(result.fingerprint()) : QString());
job = nullptr;
Q_EMIT completeChanged();
QMetaObject::invokeMethod(wizard(), "next", Qt::QueuedConnection);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment