changeset 20637:9d4ac9940d81

lib-storage: don't crash when pop3c-client timeouts
author Martti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
date Wed, 10 Aug 2016 15:40:23 +0300
parents f6e9998ddc0f
children 80642113d69a
files src/lib-storage/index/pop3c/pop3c-client.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/pop3c/pop3c-client.c	Thu Aug 11 12:46:42 2016 +0300
+++ b/src/lib-storage/index/pop3c/pop3c-client.c	Wed Aug 10 15:40:23 2016 +0300
@@ -871,6 +871,11 @@
 	struct pop3c_client_sync_cmd_ctx ctx;
 	const char *reply;
 
+	if (client->state == POP3C_CLIENT_STATE_DISCONNECTED) {
+		*error_r = "Disconnected from server";
+		return -1;
+	}
+
 	memset(&ctx, 0, sizeof(ctx));
 	*input_r = pop3c_client_cmd_stream_async(client, cmdline,
 						 pop3c_client_cmd_reply, &ctx);