From: Timo Sirainen Date: Thu, 9 May 2019 16:52:51 +0000 (+0300) Subject: global: Add asserts to make static analyzers happy X-Git-Tag: 2.3.9~508 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41e250bc898abc3b03887b603c40feb1626c7fb5;p=thirdparty%2Fdovecot%2Fcore.git global: Add asserts to make static analyzers happy --- diff --git a/src/lib-auth/auth-master.c b/src/lib-auth/auth-master.c index 753df511b3..ac43712960 100644 --- a/src/lib-auth/auth-master.c +++ b/src/lib-auth/auth-master.c @@ -289,6 +289,7 @@ static bool auth_lookup_reply_callback(const char *cmd, const char *const *args, ctx->return_value = parse_reply(ctx, cmd, args); len = str_array_length(args); + i_assert(*args != NULL || len == 0); /* for static analyzer */ if (ctx->return_value >= 0) { ctx->fields = p_new(ctx->pool, const char *, len + 1); for (i = 0; i < len; i++) diff --git a/src/lib-imap-storage/imap-msgpart.c b/src/lib-imap-storage/imap-msgpart.c index 2f9b794a52..627b44e45c 100644 --- a/src/lib-imap-storage/imap-msgpart.c +++ b/src/lib-imap-storage/imap-msgpart.c @@ -579,6 +579,8 @@ imap_msgpart_open_normal(struct mail *mail, struct imap_msgpart *msgpart, if (*msgpart->section_number != '\0') { /* find the MIME part */ + i_assert(part != NULL); + if (mail_get_stream_because(mail, NULL, NULL, "MIME part", &input) < 0) return -1; diff --git a/src/lib-mail/istream-binary-converter.c b/src/lib-mail/istream-binary-converter.c index 953e815d59..201a588152 100644 --- a/src/lib-mail/istream-binary-converter.c +++ b/src/lib-mail/istream-binary-converter.c @@ -43,6 +43,8 @@ stream_finish_convert_decision(struct binary_converter_istream *bstream) buffer_t *buf = bstream->hdr_buf; const unsigned char *data; + i_assert(bstream->convert_part != NULL); + bstream->hdr_buf = NULL; if (!part_can_convert(bstream->convert_part)) { bstream->convert_part = NULL; diff --git a/src/lib/istream-crlf.c b/src/lib/istream-crlf.c index 150195a013..6e07bb31aa 100644 --- a/src/lib/istream-crlf.c +++ b/src/lib/istream-crlf.c @@ -68,6 +68,7 @@ static ssize_t i_stream_crlf_read_crlf(struct istream_private *stream) } while (dest < dest_end) { + i_assert(src <= src_end); ptr = memchr(src, '\n', src_end - src); if (ptr == NULL) ptr = src_end; diff --git a/src/plugins/fts-lucene/lucene-wrapper.cc b/src/plugins/fts-lucene/lucene-wrapper.cc index 38b2fc78c2..4e12a4402e 100644 --- a/src/plugins/fts-lucene/lucene-wrapper.cc +++ b/src/plugins/fts-lucene/lucene-wrapper.cc @@ -1177,8 +1177,10 @@ lucene_get_query_str(struct lucene_index *index, wvalue = t_lucene_utf8_to_tchar(index, str); analyzer = guess_analyzer(index, str, strlen(str)); - if (analyzer == NULL) + if (analyzer == NULL) { analyzer = index->default_analyzer; + i_assert(analyzer != NULL); + } return getFieldQuery(analyzer, key, wvalue, fuzzy); }