From: Timo Sirainen Date: Thu, 17 Jun 2010 14:40:43 +0000 (+0100) Subject: doveadm: Don't crash when mail command that doesn't print anything uses -A. X-Git-Tag: 2.0.rc1~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f79049854ca6a69453deb5487f2b722fdae3e35;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Don't crash when mail command that doesn't print anything uses -A. --HG-- branch : HEAD --- diff --git a/src/doveadm/doveadm-mail.c b/src/doveadm/doveadm-mail.c index 1ac7916ab5..9f25557525 100644 --- a/src/doveadm/doveadm-mail.c +++ b/src/doveadm/doveadm-mail.c @@ -361,9 +361,11 @@ doveadm_mail_cmd(const struct doveadm_mail_cmd *cmd, int argc, char *argv[]) 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 --git a/src/doveadm/doveadm-print.c b/src/doveadm/doveadm-print.c index 956da28a23..3bf89852fe 100644 --- a/src/doveadm/doveadm-print.c +++ b/src/doveadm/doveadm-print.c @@ -25,6 +25,11 @@ static const struct doveadm_print_vfuncs *doveadm_print_vfuncs_all[] = { &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 --git a/src/doveadm/doveadm-print.h b/src/doveadm/doveadm-print.h index 30700eb3ca..71e4db0b9d 100644 --- a/src/doveadm/doveadm-print.h +++ b/src/doveadm/doveadm-print.h @@ -10,6 +10,8 @@ enum doveadm_print_header_flags { 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);