Mercurial > dovecot > core-2.2
changeset 22885:9648a682f05a
lib-mail: Add rfc822_parser_deinit()
It's not a strict requirement to call this, but it assert-crashes if the
state isn't valid.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 22 Dec 2017 18:56:53 +0200 |
parents | 77577228fd8f |
children | d1cb41cdebe1 |
files | src/lib-mail/rfc822-parser.h |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/rfc822-parser.h Fri Dec 22 18:42:53 2017 +0200 +++ b/src/lib-mail/rfc822-parser.h Fri Dec 22 18:56:53 2017 +0200 @@ -16,6 +16,14 @@ void rfc822_parser_init(struct rfc822_parser_context *ctx, const unsigned char *data, size_t size, string_t *last_comment) ATTR_NULL(4); +static inline void rfc822_parser_deinit(struct rfc822_parser_context *ctx) +{ + /* make sure the parsing didn't trigger a bug that caused reading + past the end pointer. */ + i_assert(ctx->data <= ctx->end); + /* make sure the parser is no longer accessed */ + ctx->data = ctx->end = NULL; +} /* The functions below return 1 = more data available, 0 = no more data available (but a value might have been returned now), -1 = invalid input.