Skip to content

Commit

Permalink
lib-mail: Add asserts to message_part_*() to make sure part->data isn…
Browse files Browse the repository at this point in the history
…'t NULL

This makes it easier to debug the crashes than just having a segfault.
  • Loading branch information
sirainen committed Jul 25, 2018
1 parent 5803ae4 commit 9753fd9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib-mail/message-part-data.c
Expand Up @@ -25,6 +25,7 @@ bool message_part_data_is_plain_7bit(const struct message_part *part)
{
const struct message_part_data *data = part->data;

i_assert(data != NULL);
i_assert(part->parent == NULL);

/* if content-type is text/xxx we don't have to check any
Expand Down Expand Up @@ -73,6 +74,8 @@ bool message_part_data_get_filename(const struct message_part *part,
const struct message_part_param *params;
unsigned int params_count, i;

i_assert(data != NULL);

params = data->content_disposition_params;
params_count = data->content_disposition_params_count;

Expand Down Expand Up @@ -539,6 +542,8 @@ bool message_part_has_content_types(struct message_part *part,
const char *const *ptr;
const char *content_type;

i_assert(data != NULL);

if (data->content_type == NULL)
return FALSE;
else if (data->content_subtype == NULL)
Expand All @@ -560,6 +565,8 @@ bool message_part_has_parameter(struct message_part *part, const char *parameter
{
struct message_part_data *data = part->data;

i_assert(data != NULL);

for (unsigned int i = 0; i < data->content_disposition_params_count; i++) {
const struct message_part_param *param =
&data->content_disposition_params[i];
Expand Down

0 comments on commit 9753fd9

Please sign in to comment.