]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
cache file: Don't crash if file has no fields.
authorTimo Sirainen <tss@iki.fi>
Thu, 16 Oct 2008 13:19:37 +0000 (16:19 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 16 Oct 2008 13:19:37 +0000 (16:19 +0300)
--HG--
branch : HEAD

src/lib-index/mail-cache-fields.c

index e44ae6c51aa91ef4ab9dcd4f58279ab0aea24e92..7dd264b1c557f5e43dfc0da09a68ed90fe8444b1 100644 (file)
@@ -155,7 +155,8 @@ mail_cache_register_get_list(struct mail_cache *cache, pool_t pool,
        if (!cache->opened)
                (void)mail_cache_open_and_verify(cache);
 
-       list = p_new(pool, struct mail_cache_field, cache->fields_count);
+       list = cache->fields_count == 0 ? NULL :
+               p_new(pool, struct mail_cache_field, cache->fields_count);
        for (i = 0; i < cache->fields_count; i++) {
                list[i] = cache->fields[i].field;
                list[i].name = p_strdup(pool, list[i].name);