[pacman-dev] [PATCH 3/7] plug memory leaks in _alpm_key_import
Andrew Gregory
andrew.gregory.8 at gmail.com
Sat Jan 16 07:20:57 UTC 2021
Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---
lib/libalpm/signing.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 2cbbd103..1f6977a0 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -505,7 +505,7 @@ int _alpm_key_import(alpm_handle_t *handle, const char *uid, const char *fpr)
}
STRDUP(fetch_key.uid, uid, return -1);
- STRDUP(fetch_key.fingerprint, fpr, return -1);
+ STRDUP(fetch_key.fingerprint, fpr, free(fetch_key.uid); return -1);
alpm_question_import_key_t question = {
.type = ALPM_QUESTION_IMPORT_KEY,
@@ -517,6 +517,7 @@ int _alpm_key_import(alpm_handle_t *handle, const char *uid, const char *fpr)
/* Try to import the key from a WKD first */
if(email_from_uid(uid, &email) == 0) {
ret = key_import_wkd(handle, email);
+ free(email);
}
/* If importing from the WKD fails, fall back to keyserver lookup */
@@ -537,6 +538,8 @@ int _alpm_key_import(alpm_handle_t *handle, const char *uid, const char *fpr)
}
}
gpgme_key_unref(fetch_key.data);
+ free(fetch_key.uid);
+ free(fetch_key.fingerprint);
return ret;
}
--
2.30.0
More information about the pacman-dev
mailing list