aboutsummaryrefslogtreecommitdiffstats
path: root/src/keylist.c
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2018-10-09 08:45:12 +0000
committerAndre Heinecke <[email protected]>2018-10-09 08:45:12 +0000
commitecfa88e65fda9c9766ad526d57e2fc8b2884f634 (patch)
tree5ce57f65ee8296a6ef8dbbd4f87a336b2027dcc7 /src/keylist.c
parentqt, tests: Add test for single get key (diff)
downloadgpgme-ecfa88e65fda9c9766ad526d57e2fc8b2884f634.tar.gz
gpgme-ecfa88e65fda9c9766ad526d57e2fc8b2884f634.zip
core: Ensure r_key init in gpgme_get_key
* src/keylist.c (gpgme_get_key): Move r_key init above the first invalid value check. -- This fixes the case where someone passes an unitialized r_key and no fingerprint.
Diffstat (limited to 'src/keylist.c')
-rw-r--r--src/keylist.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/keylist.c b/src/keylist.c
index 9c5bd4ea..6fe256ce 100644
--- a/src/keylist.c
+++ b/src/keylist.c
@@ -1266,11 +1266,12 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key,
TRACE_BEG2 (DEBUG_CTX, "gpgme_get_key", ctx,
"fpr=%s, secret=%i", fpr, secret);
+ if (r_key)
+ *r_key = NULL;
+
if (!ctx || !r_key || !fpr)
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
- *r_key = NULL;
-
if (strlen (fpr) < 8) /* We have at least a key ID. */
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));