Skip to content

Commit

Permalink
lib-index: Extension record size resizing was still broken.
Browse files Browse the repository at this point in the history
Fixes assert-crash:
Panic: file mail-index-util.c: line 143 (mail_index_seq_array_add): assertion failed: (array->arr.element_size == sizeof(seq) + aligned_record_size)
  • Loading branch information
sirainen committed Jun 14, 2016
1 parent ff9e37d commit be08677
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/lib-index/mail-index-transaction-update.c
Expand Up @@ -744,30 +744,47 @@ void mail_index_ext_resize(struct mail_index_transaction *t, uint32_t ext_id,
uint32_t hdr_size, uint16_t record_size,
uint16_t record_align)
{
const struct mail_index_registered_ext *rext;
const struct mail_transaction_ext_intro *resizes;
unsigned int resizes_count;
struct mail_transaction_ext_intro intro;
uint32_t old_record_size, old_record_align, old_header_size;
uint32_t old_record_size = 0, old_record_align, old_header_size;

memset(&intro, 0, sizeof(intro));
rext = array_idx(&t->view->index->extensions, ext_id);

/* get ext_id from transaction's map if it's there */
if (!mail_index_map_get_ext_idx(t->view->map, ext_id, &intro.ext_id)) {
/* have to create it */
const struct mail_index_registered_ext *rext;

intro.ext_id = (uint32_t)-1;
rext = array_idx(&t->view->index->extensions, ext_id);
old_record_size = rext->record_size;
old_record_align = rext->record_align;
old_header_size = rext->hdr_size;
} else {
const struct mail_index_ext *ext;

ext = array_idx(&t->view->map->extensions, intro.ext_id);
old_record_size = ext->record_size;
old_record_align = ext->record_align;
old_header_size = ext->hdr_size;
}

/* get the record size. if there are any existing record updates,
they're using the registered size, not the map's existing
record_size. */
if (array_is_created(&t->ext_resizes))
resizes = array_get(&t->ext_resizes, &resizes_count);
else {
resizes = NULL;
resizes_count = 0;
}
if (ext_id < resizes_count && resizes[ext_id].name_size != 0) {
/* already resized once. use the resized value. */
old_record_size = resizes[ext_id].record_size;
} else {
/* use the registered values. */
record_size = rext->record_size;
}

if (record_size != old_record_size) {
/* if record_size grows, we'll just resize the existing
ext_rec_updates array. it's not possible to shrink
Expand Down

0 comments on commit be08677

Please sign in to comment.