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);
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) {
r = 0;
ERROR:
+ if (result)
+ gpgme_result_unref(result);
gpgme_data_release(data);
// Free keys on error