]> granicus.if.org Git - neomutt/commitdiff
Avoid segfault when an IMAP connection cannot be opened
authorPietro Cerutti <gahr@gahr.ch>
Fri, 16 Nov 2018 09:42:51 +0000 (09:42 +0000)
committerPietro Cerutti <gahr@gahr.ch>
Fri, 16 Nov 2018 09:42:51 +0000 (09:42 +0000)
This could be reproduced trying to open an IMAPS connection with a
NeoMutt built without SSL support.

imap/imap.c
mx.c

index 543087b3005801b1b34fc4b66ad49f96e085b26e..a75b98eecf90252918f321b8e909621f0207ccb0 100644 (file)
@@ -751,6 +751,9 @@ void imap_logout_all(void)
       continue;
 
     struct ImapAccountData *adata = np->adata;
+    if (!adata)
+        continue;
+
     struct Connection *conn = adata->conn;
     if (!conn || (conn->fd < 0))
       continue;
diff --git a/mx.c b/mx.c
index 00f14e711d4e4f8b32eccb1c712c8fcf4c4c7cb6..53bcba3a541ef8ef34fbdf05f77429e78208a7d4 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -282,7 +282,12 @@ struct Context *mx_mbox_open(struct Mailbox *m, const char *path, int flags)
     m->account = a;
     a->magic = m->magic;
     TAILQ_INSERT_TAIL(&AllAccounts, a, entries);
-    mx_ac_add(a, m);
+    if (mx_ac_add(a, m) < 0)
+    {
+      //error
+      mailbox_free(&m);
+      return NULL;
+    }
   }
 
 #if 0