From 9c9d252ca6e4a311e524ab688ec8eafb64fe7bc3 Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Mon, 10 Sep 2018 07:44:52 +0000 Subject: [PATCH] Fix check on empty strings --- curs_main.c | 15 +++++++++------ mailbox.c | 4 ++-- mbox/mbox.c | 2 +- pager.c | 2 +- sidebar.c | 2 +- status.c | 5 +++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/curs_main.c b/curs_main.c index 2026397b2..4c242c5ac 100644 --- a/curs_main.c +++ b/curs_main.c @@ -563,7 +563,7 @@ static int main_change_folder(struct Menu *menu, int op, char *buf, } /* keepalive failure in mutt_enter_fname may kill connection. #3028 */ - if (Context && !Context->mailbox->path) + if (Context && (Context->mailbox->path[0] == '\0')) mutt_context_free(&Context); if (Context) @@ -573,7 +573,8 @@ static int main_change_folder(struct Menu *menu, int op, char *buf, int monitor_remove_rc = mutt_monitor_remove(NULL); #endif #ifdef USE_COMPRESSED - if (Context->mailbox->compress_info && Context->mailbox->realpath) + if (Context->mailbox->compress_info && + (Context->mailbox->realpath[0] != '\0')) new_last_folder = mutt_str_strdup(Context->mailbox->realpath); else #endif @@ -1052,7 +1053,7 @@ int mutt_index_menu(void) check = mx_mbox_check(Context, &index_hint); if (check < 0) { - if (!Context->mailbox->path) + if (Context->mailbox->path[0] == '\0') { /* fatal error occurred */ mutt_context_free(&Context); @@ -1887,7 +1888,7 @@ int mutt_index_menu(void) } /* check for a fatal error, or all messages deleted */ - if (!Context->mailbox->path) + if (Context->mailbox->path[0] == '\0') mutt_context_free(&Context); /* if we were in the pager, redisplay the message */ @@ -2160,7 +2161,8 @@ int mutt_index_menu(void) cp = _("Open mailbox"); buf[0] = '\0'; - if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->mailbox->path) + if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && + (Context->mailbox->path[0] != '\0')) { mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf)); mutt_pretty_mailbox(buf, sizeof(buf)); @@ -2201,7 +2203,8 @@ int mutt_index_menu(void) #endif else { - if (ChangeFolderNext && Context && Context->mailbox->path) + if (ChangeFolderNext && Context && + (Context->mailbox->path[0] != '\0')) { mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf)); mutt_pretty_mailbox(buf, sizeof(buf)); diff --git a/mailbox.c b/mailbox.c index 9708047eb..e1d1af950 100644 --- a/mailbox.c +++ b/mailbox.c @@ -444,7 +444,7 @@ static void mailbox_check(struct Mailbox *tmp, struct stat *contex_sb, bool chec } /* check to see if the folder is the currently selected folder before polling */ - if (!Context || !Context->mailbox->path || + if (!Context || (Context->mailbox->path[0] == '\0') || ((tmp->magic == MUTT_IMAP || #ifdef USE_NNTP tmp->magic == MUTT_NNTP || @@ -489,7 +489,7 @@ static void mailbox_check(struct Mailbox *tmp, struct stat *contex_sb, bool chec default:; /* do nothing */ } } - else if (CheckMboxSize && Context && Context->mailbox->path) + else if (CheckMboxSize && Context && (Context->mailbox->path[0] != '\0')) tmp->size = (off_t) sb.st_size; /* update the size of current folder */ #ifdef USE_SIDEBAR diff --git a/mbox/mbox.c b/mbox/mbox.c index dc2a3e8b1..2451ac452 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -642,7 +642,7 @@ static int mbox_mbox_close(struct Context *ctx) mutt_file_fclose(&mdata->fp); /* fix up the times so mailbox won't get confused */ - if (ctx->peekonly && ctx->mailbox->path && + if (ctx->peekonly && (ctx->mailbox->path[0] != '\0') && (mutt_timespec_compare(&ctx->mailbox->mtime, &mdata->atime) > 0)) { #ifdef HAVE_UTIMENSAT diff --git a/pager.c b/pager.c index 3cfaea161..24d01a3d0 100644 --- a/pager.c +++ b/pager.c @@ -2342,7 +2342,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e check = mx_mbox_check(Context, &index_hint); if (check < 0) { - if (!Context->mailbox->path) + if (Context->mailbox->path[0] == '\0') { /* fatal error occurred */ mutt_context_free(&Context); diff --git a/sidebar.c b/sidebar.c index bea3afdca..d82502efc 100644 --- a/sidebar.c +++ b/sidebar.c @@ -863,7 +863,7 @@ static void draw_sidebar(int num_rows, int num_cols, int div_width) col = div_width; mutt_window_move(MuttSidebarWindow, row, col); - if (Context && Context->mailbox->realpath && + if (Context && (Context->mailbox->realpath[0] != '\0') && (mutt_str_strcmp(m->realpath, Context->mailbox->realpath) == 0)) { #ifdef USE_NOTMUCH diff --git a/status.c b/status.c index 6b057f919..a29a56635 100644 --- a/status.c +++ b/status.c @@ -131,14 +131,15 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c else #endif #ifdef USE_COMPRESSED - if (Context && Context->mailbox->compress_info && Context->mailbox->realpath) + if (Context && Context->mailbox->compress_info && + (Context->mailbox->realpath[0] != '\0')) { mutt_str_strfcpy(tmp, Context->mailbox->realpath, sizeof(tmp)); mutt_pretty_mailbox(tmp, sizeof(tmp)); } else #endif - if (Context && Context->mailbox->path) + if (Context && (Context->mailbox->path[0] != '\0')) { mutt_str_strfcpy(tmp, Context->mailbox->path, sizeof(tmp)); mutt_pretty_mailbox(tmp, sizeof(tmp)); -- 2.40.0