changeset 11567:c9b793187ca6 HEAD

doveadm: Don't crash when mail command that doesn't print anything uses -A.
author Timo Sirainen <tss@iki.fi>
date Thu, 17 Jun 2010 15:40:43 +0100
parents 744638eb4c1a
children 81e496a5b412
files src/doveadm/doveadm-mail.c src/doveadm/doveadm-print.c src/doveadm/doveadm-print.h
diffstat 3 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/doveadm-mail.c	Thu Jun 17 15:14:31 2010 +0100
+++ b/src/doveadm/doveadm-mail.c	Thu Jun 17 15:40:43 2010 +0100
@@ -361,9 +361,11 @@
 		switch (c) {
 		case 'A':
 			ctx->iterate_all_users = TRUE;
-			doveadm_print_header("username", "Username",
-				DOVEADM_PRINT_HEADER_FLAG_STICKY |
-				DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE);
+			if (doveadm_print_is_initialized()) {
+				doveadm_print_header("username", "Username",
+					DOVEADM_PRINT_HEADER_FLAG_STICKY |
+					DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE);
+			}
 			break;
 		case 'u':
 			service_flags |=
--- a/src/doveadm/doveadm-print.c	Thu Jun 17 15:14:31 2010 +0100
+++ b/src/doveadm/doveadm-print.c	Thu Jun 17 15:40:43 2010 +0100
@@ -25,6 +25,11 @@
 	&doveadm_print_table_vfuncs
 };
 
+bool doveadm_print_is_initialized(void)
+{
+	return ctx != NULL;
+}
+
 void doveadm_print_header(const char *key, const char *title,
 			  enum doveadm_print_header_flags flags)
 {
--- a/src/doveadm/doveadm-print.h	Thu Jun 17 15:14:31 2010 +0100
+++ b/src/doveadm/doveadm-print.h	Thu Jun 17 15:40:43 2010 +0100
@@ -10,6 +10,8 @@
 	DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE	 	= 0x04
 };
 
+bool doveadm_print_is_initialized(void);
+
 void doveadm_print_header(const char *key, const char *title,
 			  enum doveadm_print_header_flags flags);
 void doveadm_print_header_simple(const char *key_title);