]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Add asserts to make static analyzers happy
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 9 May 2019 16:52:51 +0000 (19:52 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 25 Jun 2019 11:58:15 +0000 (14:58 +0300)
src/lib-auth/auth-master.c
src/lib-imap-storage/imap-msgpart.c
src/lib-mail/istream-binary-converter.c
src/lib/istream-crlf.c
src/plugins/fts-lucene/lucene-wrapper.cc

index 753df511b3feacfedfa99776dfb661d89283d364..ac437129601cd847b9eda838d4909d24c21f4353 100644 (file)
@@ -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++)
index 9ee93895e5509974d6654c93eabbda62523fcc96..5ad5954d895623671c09c9ae2e69bbe0b6d87580 100644 (file)
@@ -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;
 
index 953e815d59eb4d1b8990928dad0fed518c35e100..201a58815295421c39c03f78addd19bc1f8f9da0 100644 (file)
@@ -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;
index 150195a01315f7e8f3cdb6eececee7e987fef5d1..6e07bb31aa7e1636d984adfcc502d332ea3a5f73 100644 (file)
@@ -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;
index 38b2fc78c2b5d692d18e95bc5b2cd55b4eb13451..4e12a4402eb22b69271af516322fd34e43e8379d 100644 (file)
@@ -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);
 }