]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Remove size from struct mail_keywords.idx[]
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Sep 2017 20:24:01 +0000 (23:24 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Sep 2017 20:24:01 +0000 (23:24 +0300)
This was confusing static analyzers, which thought that using [1] meant that
its size really was 1.

src/lib-index/mail-index.c
src/lib-index/mail-index.h

index 84042b753e9bba1b0ec6b3119576f7886c1bd331..1cc68ff9808c52953923d209284ba1ae575cb03e 100644 (file)
@@ -382,7 +382,7 @@ mail_index_keywords_create(struct mail_index *index,
 
        /* @UNSAFE */
        k = i_malloc(MALLOC_ADD(sizeof(struct mail_keywords),
-                               MALLOC_MULTIPLY(sizeof(k->idx), (count-1))));
+                               MALLOC_MULTIPLY(sizeof(k->idx[0]), count)));
        k->index = index;
        k->refcount = 1;
 
@@ -422,7 +422,7 @@ mail_index_keywords_create_from_indexes(struct mail_index *index,
 
        /* @UNSAFE */
        k = i_malloc(MALLOC_ADD(sizeof(struct mail_keywords),
-                               MALLOC_MULTIPLY(sizeof(k->idx), (count-1))));
+                               MALLOC_MULTIPLY(sizeof(k->idx[0]), count)));
        k->index = index;
        k->refcount = 1;
 
index 687e051b138bc3fa055e874fa6f997d518472ac9..ead8130f1c8f907c61f8253f38dfb822db325daf 100644 (file)
@@ -129,7 +129,7 @@ struct mail_keywords {
        int refcount;
 
         /* variable sized list of keyword indexes */
-       unsigned int idx[1];
+       unsigned int idx[FLEXIBLE_ARRAY_MEMBER];
 };
 
 enum mail_index_transaction_flags {