# HG changeset patch # User Timo Sirainen # Date 1451926932 18000 # Node ID 7104de5201414a3fab37496b5ee81978c8432621 # Parent 0c2e2cba8a5ba7b5ef61523657d0b8e63a8a7d86 lib-storage: mail_add_temp_wanted_fields() was reading already-freed memory. This mainly happened with mail_log plugin enabled. diff -r 0c2e2cba8a5b -r 7104de520141 src/lib-storage/index/index-mail.c --- a/src/lib-storage/index/index-mail.c Mon Jan 04 11:47:24 2016 -0500 +++ b/src/lib-storage/index/index-mail.c Mon Jan 04 12:02:12 2016 -0500 @@ -1816,6 +1816,7 @@ { struct index_mail *mail = (struct index_mail *)_mail; struct index_mail_data *data = &mail->data; + struct mailbox_header_lookup_ctx *new_wanted_headers; ARRAY_TYPE(const_string) names; unsigned int i; @@ -1833,11 +1834,12 @@ for (i = 0; i < headers->count; i++) array_append(&names, &headers->name[i], 1); array_append_zero(&names); + new_wanted_headers = + mailbox_header_lookup_init(_mail->box, + array_idx(&names, 0)); if (data->wanted_headers != NULL) mailbox_header_lookup_unref(&data->wanted_headers); - data->wanted_headers = - mailbox_header_lookup_init(_mail->box, - array_idx(&names, 0)); + data->wanted_headers = new_wanted_headers; } index_mail_update_access_parts_pre(_mail); index_mail_update_access_parts_post(_mail);