From 8cfcdfe5564f87362e5ec1bfdca5c14aed9c45f0 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 16 Mar 2015 13:40:34 +0100 Subject: [PATCH] Fix potential crash in trace macro. * src/signers.c (gpgme_signers_add): Avoid deref of a NULL KEY in the trace macro. * src/engine-spawn.c (engspawn_release): Remove always true condition. * src/engine-gpg.c (gpg_release): Ditto. Signed-off-by: Werner Koch --- src/engine-gpg.c | 3 +-- src/engine-spawn.c | 3 +-- src/signers.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 30c3bfbe..57aea8b0 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -396,8 +396,7 @@ gpg_release (void *engine) { struct arg_and_data_s *next = gpg->arglist->next; - if (gpg->arglist) - free (gpg->arglist); + free (gpg->arglist); gpg->arglist = next; } diff --git a/src/engine-spawn.c b/src/engine-spawn.c index 28a14bed..eb4e0385 100644 --- a/src/engine-spawn.c +++ b/src/engine-spawn.c @@ -355,8 +355,7 @@ engspawn_release (void *engine) { struct datalist_s *next = esp->arglist->next; - if (esp->arglist) - free (esp->arglist); + free (esp->arglist); esp->arglist = next; } diff --git a/src/signers.c b/src/signers.c index f43fafc7..f540d700 100644 --- a/src/signers.c +++ b/src/signers.c @@ -66,7 +66,7 @@ gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key) { TRACE_BEG2 (DEBUG_CTX, "gpgme_signers_add", ctx, - "key=%p (%s)", key, (key->subkeys && key->subkeys->fpr) ? + "key=%p (%s)", key, (key && key->subkeys && key->subkeys->fpr) ? key->subkeys->fpr : "invalid"); if (!ctx || !key)