changeset 21978:225072babbce

lib-imap-client: Fix imapc_client_get_capabilities() when called without connections
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 23 Apr 2017 19:57:11 +0300
parents 3fcf9d9fa53f
children 93b58b983718
files src/lib-imap-client/imapc-client.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap-client/imapc-client.c	Sun Apr 23 17:19:36 2017 +0300
+++ b/src/lib-imap-client/imapc-client.c	Sun Apr 23 19:57:11 2017 +0300
@@ -530,8 +530,11 @@
 	if (imapc_client_get_any_capabilities(client, capabilities_r))
 		return 0;
 
-	/* wait for any of the connections to login (there always exists one) */
-	i_assert(array_count(&client->conns) > 0);
+	/* if there are no connections yet, create one */
+	if (array_count(&client->conns) == 0)
+		(void)imapc_client_add_connection(client);
+
+	/* wait for any of the connections to login */
 	imapc_client_run(client);
 	if (imapc_client_get_any_capabilities(client, capabilities_r))
 		return 0;