This will fix possible NULL pointer dereference when caller does not set last_comment. --- src/lib-mail/message-address.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib-mail/message-address.c b/src/lib-mail/message-address.c index 9ce4a55..4e86185 100644 --- a/src/lib-mail/message-address.c +++ b/src/lib-mail/message-address.c @@ -158,7 +158,8 @@ static int parse_addr_spec(struct message_address_parser_context *ctx) /* addr-spec = local-part "@" domain */ int ret, ret2; - str_truncate(ctx->parser.last_comment, 0); + if (ctx->parser.last_comment != NULL) + str_truncate(ctx->parser.last_comment, 0); ret = parse_local_part(ctx); if (ret != 0 && *ctx->parser.data == '@') { @@ -167,9 +168,11 @@ static int parse_addr_spec(struct message_address_parser_context *ctx) ret = ret2; } - if (str_len(ctx->parser.last_comment) > 0) { - ctx->addr.name = - p_strdup(ctx->pool, str_c(ctx->parser.last_comment)); + if (ctx->parser.last_comment != NULL) { + if (str_len(ctx->parser.last_comment) > 0) { + ctx->addr.name = + p_strdup(ctx->pool, str_c(ctx->parser.last_comment)); + } } return ret; } -- 1.7.9.5