From: Michael Tremer Date: Sat, 7 Aug 2021 19:34:02 +0000 (+0000) Subject: key: Keep import result so that we can call pakfire_find_key X-Git-Tag: 0.9.28~1003 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=548535a173085389d0e73971de2516ebe2d307f7;p=pakfire.git key: Keep import result so that we can call pakfire_find_key Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/key.c b/src/libpakfire/key.c index 8548db452..392a2f5a7 100644 --- a/src/libpakfire/key.c +++ b/src/libpakfire/key.c @@ -477,13 +477,13 @@ PAKFIRE_EXPORT int pakfire_key_import(struct pakfire* pakfire, FILE* f, if (!gpgctx) return 1; + gpgme_import_result_t result = NULL; + // Import key data gpgme_error_t e = gpgme_data_new_from_stream(&data, f); if (gpg_error(e) != GPG_ERR_NO_ERROR) goto ERROR; - gpgme_import_result_t result = NULL; - // Try importing the key(s) e = gpgme_op_import(gpgctx, data); @@ -492,6 +492,9 @@ PAKFIRE_EXPORT int pakfire_key_import(struct pakfire* pakfire, FILE* f, case GPG_ERR_NO_ERROR: result = gpgme_op_import_result(gpgctx); + // Keep the result + gpgme_result_ref(result); + // Did we import any keys? gpgme_import_status_t status = result->imports; if (!status) { @@ -538,6 +541,8 @@ PAKFIRE_EXPORT int pakfire_key_import(struct pakfire* pakfire, FILE* f, r = 0; ERROR: + if (result) + gpgme_result_unref(result); gpgme_data_release(data); // Free keys on error