]> git.ipfire.org Git - pakfire.git/commitdiff
key: Keep import result so that we can call pakfire_find_key
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 7 Aug 2021 19:34:02 +0000 (19:34 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 7 Aug 2021 19:34:02 +0000 (19:34 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/key.c

index 8548db452a85b3608b88dc7c276c4e1ff75f435c..392a2f5a75c5d169987d1387493875e36fd21249 100644 (file)
@@ -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