changeset 11590:542d859f0223 HEAD

doveadm: Table formatter crashed with large output.
author Timo Sirainen <tss@iki.fi>
date Mon, 21 Jun 2010 15:26:00 +0100
parents 573cb66e9180
children 4e54843f11d0
files src/doveadm/doveadm-print-table.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/doveadm-print-table.c	Sat Jun 19 20:57:42 2010 +0100
+++ b/src/doveadm/doveadm-print-table.c	Mon Jun 21 15:26:00 2010 +0100
@@ -154,8 +154,12 @@
 
 static void doveadm_print_table_print(const char *value)
 {
+	unsigned int line_count;
+
 	if (!ctx->lengths_set) {
-		if (array_count(&ctx->buffered_values) < MAX_BUFFER_LINES) {
+		line_count = array_count(&ctx->buffered_values) /
+			array_count(&ctx->headers);
+		if (line_count < MAX_BUFFER_LINES) {
 			value = p_strdup(ctx->pool, value);
 			array_append(&ctx->buffered_values, &value, 1);
 			return;