]> granicus.if.org Git - neomutt/commitdiff
add pointer checks to gpgme
authorRichard Russon <rich@flatcap.org>
Mon, 13 Nov 2017 11:42:45 +0000 (11:42 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 15 Nov 2017 15:12:11 +0000 (15:12 +0000)
ncrypt/crypt_gpgme.c

index 2efc589683c30d10b9c56f6146a227f838ba4674..4d7f4994f3d09f2ec6b42d8892e353b64df3fea9 100644 (file)
@@ -382,6 +382,9 @@ static bool crypt_key_is_valid(struct CryptKeyInfo *k)
  */
 static int crypt_id_is_strong(struct CryptKeyInfo *key)
 {
+  if (!key)
+    return 0;
+
   unsigned int is_strong = 0;
 
   if ((key->flags & KEYFLAG_ISX509))
@@ -411,6 +414,9 @@ static int crypt_id_is_strong(struct CryptKeyInfo *key)
  */
 static int crypt_id_is_valid(struct CryptKeyInfo *key)
 {
+  if (!key)
+    return 0;
+
   return !(key->flags & KEYFLAG_CANTUSE);
 }
 
@@ -431,13 +437,20 @@ static int crypt_id_matches_addr(struct Address *addr, struct Address *u_addr,
   if (crypt_id_is_strong(key))
     rv |= CRYPT_KV_STRONGID;
 
-  if (addr->mailbox && u_addr->mailbox &&
-      (mutt_strcasecmp(addr->mailbox, u_addr->mailbox) == 0))
-    rv |= CRYPT_KV_ADDR;
+  if (addr && u_addr)
+  {
+    if (addr->mailbox && u_addr->mailbox &&
+        (mutt_strcasecmp(addr->mailbox, u_addr->mailbox) == 0))
+    {
+      rv |= CRYPT_KV_ADDR;
+    }
 
-  if (addr->personal && u_addr->personal &&
-      (mutt_strcasecmp(addr->personal, u_addr->personal) == 0))
-    rv |= CRYPT_KV_STRING;
+    if (addr->personal && u_addr->personal &&
+        (mutt_strcasecmp(addr->personal, u_addr->personal) == 0))
+    {
+      rv |= CRYPT_KV_STRING;
+    }
+  }
 
   return rv;
 }