]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Don't crash when mail command that doesn't print anything uses -A.
authorTimo Sirainen <tss@iki.fi>
Thu, 17 Jun 2010 14:40:43 +0000 (15:40 +0100)
committerTimo Sirainen <tss@iki.fi>
Thu, 17 Jun 2010 14:40:43 +0000 (15:40 +0100)
--HG--
branch : HEAD

src/doveadm/doveadm-mail.c
src/doveadm/doveadm-print.c
src/doveadm/doveadm-print.h

index 1ac7916ab5a4ca6348eac142936e8f3faf758897..9f25557525ab714ef3961f93f71bdfaeaab9dccb 100644 (file)
@@ -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 |=
index 956da28a23a982a25d872326957bbe45819b8913..3bf89852fec6c20afb5266c01b6da5eeaa6f7c71 100644 (file)
@@ -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)
 {
index 30700eb3ca38383929ad765a795c6e98bc12f522..71e4db0b9da6f9e1a7180855be0ededd9dff73f9 100644 (file)
@@ -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);