[balsa] Do not dereference a NULL pointer



commit 02f660bc47319fa1ad21781f8d487bba682a16d3
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Jul 17 11:25:14 2017 -0400

    Do not dereference a NULL pointer
    
        * libbalsa/libbalsa-gpgme.c (get_key_from_name): do not
        dereference a NULL pointer.

 ChangeLog                 |    5 +++++
 libbalsa/libbalsa-gpgme.c |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b4fcb08..77f4dbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2017-07-17  Peter Bloomfield  <pbloomfield bellsouth net>
 
+       * libbalsa/libbalsa-gpgme.c (get_key_from_name): do not
+       dereference a NULL pointer.
+
+2017-07-17  Peter Bloomfield  <pbloomfield bellsouth net>
+
        Avoid some whining from the clang static analyzer
 
        * libbalsa/libbalsa-gpgme-keys.c (gpgme_import_key):
diff --git a/libbalsa/libbalsa-gpgme.c b/libbalsa/libbalsa-gpgme.c
index d0641bd..3f71895 100644
--- a/libbalsa/libbalsa-gpgme.c
+++ b/libbalsa/libbalsa-gpgme.c
@@ -791,7 +791,8 @@ get_key_from_name(gpgme_ctx_t   ctx,
 
        /* OpenPGP: ask the user if a low-validity key should be trusted for encryption */
        // FIXME - shouldn't we do the same for S/MIME?
-       if ((result == GPG_ERR_NO_ERROR) && !secret && !accept_all && (gpgme_get_protocol(ctx) == 
GPGME_PROTOCOL_OpenPGP) &&
+       if ((selected != NULL) &&
+                (result == GPG_ERR_NO_ERROR) && !secret && !accept_all && (gpgme_get_protocol(ctx) == 
GPGME_PROTOCOL_OpenPGP) &&
                (selected->owner_trust < GPGME_VALIDITY_FULL)) {
                if ((accept_low_trust_cb == NULL) || !accept_low_trust_cb(name, selected, parent)) {
                        gpgme_key_unref(selected);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]