From: Timo Sirainen Date: Wed, 13 Sep 2017 20:24:01 +0000 (+0300) Subject: lib-index: Remove size from struct mail_keywords.idx[] X-Git-Tag: 2.3.0.rc1~1026 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9c93b5764f84126b3362cd96da4bd9b4de078bc7;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Remove size from struct mail_keywords.idx[] This was confusing static analyzers, which thought that using [1] meant that its size really was 1. --- diff --git a/src/lib-index/mail-index.c b/src/lib-index/mail-index.c index 84042b753e..1cc68ff980 100644 --- a/src/lib-index/mail-index.c +++ b/src/lib-index/mail-index.c @@ -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; diff --git a/src/lib-index/mail-index.h b/src/lib-index/mail-index.h index 687e051b13..ead8130f1c 100644 --- a/src/lib-index/mail-index.h +++ b/src/lib-index/mail-index.h @@ -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 {