dovecot-2.0: doveadm: Don't crash when mail command that doesn't...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jun 17 17:40:47 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/c9b793187ca6
changeset: 11567:c9b793187ca6
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jun 17 15:40:43 2010 +0100
description:
doveadm: Don't crash when mail command that doesn't print anything uses -A.

diffstat:

 src/doveadm/doveadm-mail.c  |  8 +++++---
 src/doveadm/doveadm-print.c |  5 +++++
 src/doveadm/doveadm-print.h |  2 ++
 3 files changed, 12 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 744638eb4c1a -r c9b793187ca6 src/doveadm/doveadm-mail.c
--- 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 |=
diff -r 744638eb4c1a -r c9b793187ca6 src/doveadm/doveadm-print.c
--- 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)
 {
diff -r 744638eb4c1a -r c9b793187ca6 src/doveadm/doveadm-print.h
--- 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);


More information about the dovecot-cvs mailing list