Skip to content

Commit

Permalink
lib-storage: Add asserts to make sure mailbox_header_lookup_ctx is us…
Browse files Browse the repository at this point in the history
…ed correctly.
  • Loading branch information
sirainen authored and GitLab committed Nov 18, 2016
1 parent 9e6d83a commit 045d594
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/lib-storage/index/index-mail-headers.c
Expand Up @@ -862,9 +862,6 @@ int index_mail_get_header_stream(struct mail *_mail,
struct istream *input;
string_t *dest;

i_assert(headers->count > 0);
i_assert(headers->box == _mail->box);

if (mail->data.save_bodystructure_header) {
/* we have to parse the header. */
const char *reason =
Expand Down
2 changes: 2 additions & 0 deletions src/lib-storage/mail-storage.c
Expand Up @@ -1803,6 +1803,8 @@ mailbox_search_init(struct mailbox_transaction_context *t,
enum mail_fetch_field wanted_fields,
struct mailbox_header_lookup_ctx *wanted_headers)
{
i_assert(wanted_headers == NULL || wanted_headers->box == t->box);

mail_search_args_ref(args);
if (!args->simplified)
mail_search_args_simplify(args);
Expand Down
7 changes: 7 additions & 0 deletions src/lib-storage/mail.c
Expand Up @@ -19,6 +19,8 @@ struct mail *mail_alloc(struct mailbox_transaction_context *t,
{
struct mail *mail;

i_assert(wanted_headers == NULL || wanted_headers->box == t->box);

T_BEGIN {
mail = t->box->v.mail_alloc(t, wanted_fields, wanted_headers);
hook_mail_allocated(mail);
Expand Down Expand Up @@ -73,6 +75,8 @@ void mail_add_temp_wanted_fields(struct mail *mail,
{
struct mail_private *p = (struct mail_private *)mail;

i_assert(headers == NULL || headers->box == mail->box);

p->v.add_temp_wanted_fields(mail, fields, headers);
}

Expand Down Expand Up @@ -232,6 +236,9 @@ int mail_get_header_stream(struct mail *mail,
struct mail_private *p = (struct mail_private *)mail;
int ret;

i_assert(headers->count > 0);
i_assert(headers->box == mail->box);

T_BEGIN {
ret = p->v.get_header_stream(mail, headers, stream_r);
} T_END;
Expand Down

0 comments on commit 045d594

Please sign in to comment.