changeset 20525:49ab9d8293ba

dict: Fixed crash on iteration handling.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 14 Jul 2016 16:16:52 -0500
parents 46d7324c8246
children 9565305a8512
files src/dict/dict-commands.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/dict/dict-commands.c	Thu Jul 14 07:22:04 2016 -0500
+++ b/src/dict/dict-commands.c	Thu Jul 14 16:16:52 2016 -0500
@@ -173,7 +173,6 @@
 
 	cmd_stats_update(cmd, cmd_stats.iterations);
 	cmd->reply = i_strdup(str_c(str));
-	dict_connection_cmds_flush(cmd->conn);
 	return 1;
 }
 
@@ -495,8 +494,10 @@
 	struct dict_connection_cmd *const *first_cmdp;
 	
 	first_cmdp = array_idx(&cmd->conn->cmds, 0);
-	if (*first_cmdp == cmd)
-		(void)cmd_iterate_flush(cmd);
+	if (*first_cmdp == cmd) {
+		if (cmd_iterate_flush(cmd) > 0)
+			dict_connection_cmds_flush(cmd->conn);
+	}
 }
 
 void dict_connection_cmds_output_more(struct dict_connection *conn)
@@ -515,6 +516,7 @@
 			/* unfinished */
 			break;
 		}
+		dict_connection_cmds_flush(cmd->conn);
 		/* cmd should be freed now */
 	}
 }