]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: ref/unref input stream in http message parser
authorPhil Carmody <phil@dovecot.fi>
Mon, 16 Nov 2015 10:26:06 +0000 (12:26 +0200)
committerPhil Carmody <phil@dovecot.fi>
Mon, 16 Nov 2015 10:26:06 +0000 (12:26 +0200)
To prevent assidental disappearance of the stream while it's in use.
Also, the caller can create and forget - we'll do the cleanup later.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib-http/http-message-parser.c

index c36518e243fe67eb9fd36afa1572940fb164130f..61b11c95f3d82c92e4edf377e17022ccaedeef1d 100644 (file)
@@ -20,6 +20,7 @@ void http_message_parser_init(struct http_message_parser *parser,
 {
        memset(parser, 0, sizeof(*parser));
        parser->input = input;
+       i_stream_ref(parser->input);
        if (hdr_limits != NULL)
                parser->header_limits = *hdr_limits;
        parser->max_payload_size = max_payload_size;
@@ -34,6 +35,8 @@ void http_message_parser_deinit(struct http_message_parser *parser)
                pool_unref(&parser->msg.pool);
        if (parser->payload != NULL)
                i_stream_unref(&parser->payload);
+       if (parser->input != NULL)
+               i_stream_unref(&parser->input);
 }
 
 void http_message_parser_restart(struct http_message_parser *parser,