mutt_debug(1, "Error parsing %s\n", path);
return -1;
}
- if (!(*hidata = imap_conn_find(&(mx.account), ImapPassive ? MUTT_IMAP_CONN_NONEW : 0)) ||
- (*hidata)->state < IMAP_AUTHENTICATED)
+
+ *hidata = imap_conn_find(&(mx.account), ImapPassive ? MUTT_IMAP_CONN_NONEW : 0);
+ if (!*hidata)
{
FREE(&mx.mbox);
return -1;
* imap_conn_find - Find an open IMAP connection
* @param account ConnAccount to search
* @param flags Flags, e.g. #MUTT_IMAP_CONN_NONEW
- * @retval ptr Matching connection
- * @retval NULL Failure
+ * @retval ptr Authenticated connection
+ * @retval NULL Failure, or no matching authenticated connections
*
* Find an open IMAP connection matching account, or open a new one if none can
* be found.
if (!conn)
return NULL; /* this happens when the initial connection fails */
+ /* The current connection is a new connection */
if (!mdata)
{
/* The current connection is a new connection */
mdata = imap_mdata_new();
- if (!mdata)
- {
- mutt_socket_free(conn);
- return NULL;
- }
-
conn->data = mdata;
mdata->conn = conn;
new = true;
imap_exec(mdata, NULL, IMAP_CMD_FAIL_OK);
}
+ if (mdata->state < IMAP_AUTHENTICATED)
+ return NULL;
+
return mdata;
}