From 2aaf39a8b49affb264ef28e7464fc8ef92209c88 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Thu, 12 Apr 2007 12:55:29 +0200 Subject: [PATCH] fix segfault when gpg is not present. Signed-off-by: Pierre Habouzit --- crypt.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/crypt.c b/crypt.c index e137f2c..2273165 100644 --- a/crypt.c +++ b/crypt.c @@ -560,18 +560,15 @@ static char *encrypt_gpgme_object(gpgme_data_t plaintext, gpgme_key_t *rset, static int get_micalg(gpgme_ctx_t ctx, char *buf, ssize_t buflen) { gpgme_sign_result_t result = NULL; - const char *algorithm_name = NULL; + const char *alg = NULL; - *buf = '\0'; result = gpgme_op_sign_result(ctx); - if (result) { - algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo); - if (algorithm_name) { - m_strcpy(buf, buflen, algorithm_name); - } + if (result && result->signatures) { + alg = gpgme_hash_algo_name(result->signatures->hash_algo); } + m_strcpy(buf, buflen, NONULL(alg)); - return *buf ? 0 : -1; + return alg ? 0 : -1; } static void print_time(time_t t, STATE *s) -- 2.20.1