From 9035aa83aad0017fffb8b12887313fa71d73c209 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Wed, 17 Jan 2018 16:06:07 +0000 Subject: [PATCH] forward null checks --- conn/ssl_gnutls.c | 2 +- curs_lib.c | 3 +++ curs_main.c | 2 +- menu.c | 3 +++ mutt/file.c | 3 +++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/conn/ssl_gnutls.c b/conn/ssl_gnutls.c index b9c8b7dc8..9bda6b7f4 100644 --- a/conn/ssl_gnutls.c +++ b/conn/ssl_gnutls.c @@ -823,7 +823,7 @@ static int tls_check_one_certificate(const gnutls_datum_t *certdata, break; case OP_MAX + 3: /* accept always */ done = 0; - fp = fopen(CertificateFile, "a"); + fp = mutt_file_fopen(CertificateFile, "a"); if (fp) { /* save hostname if necessary */ diff --git a/curs_lib.c b/curs_lib.c index 65042a9e3..0b8d2a65c 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -755,6 +755,9 @@ int mutt_window_mvprintw(struct MuttWindow *win, int row, int col, const char *f */ void mutt_window_clrtoeol(struct MuttWindow *win) { + if (!win || !stdscr) + return; + int row, col, curcol; if (win->col_offset + win->cols == COLS) diff --git a/curs_main.c b/curs_main.c index 94cee9f6c..1a12583bb 100644 --- a/curs_main.c +++ b/curs_main.c @@ -708,7 +708,7 @@ void mutt_draw_statusline(int cols, const char *buf, int buflen) int last; } *syntax = NULL; - if (!buf) + if (!buf || !stdscr) return; do diff --git a/menu.c b/menu.c index dbe7df1ec..cbc05f137 100644 --- a/menu.c +++ b/menu.c @@ -104,6 +104,9 @@ static void print_enriched_string(int index, int attr, unsigned char *s, int do_ size_t n = mutt_str_strlen((char *) s); mbstate_t mbstate; + if (!stdscr) + return; + memset(&mbstate, 0, sizeof(mbstate)); while (*s) { diff --git a/mutt/file.c b/mutt/file.c index 982a16dd3..471b2b0be 100644 --- a/mutt/file.c +++ b/mutt/file.c @@ -555,6 +555,9 @@ int mutt_file_open(const char *path, int flags) */ FILE *mutt_file_fopen(const char *path, const char *mode) { + if (!path || !mode) + return NULL; + if (mode[0] == 'w') { int fd; -- 2.40.0