Mercurial > dovecot > core-2.2
changeset 21557:219ec946f7c3
lib-http: message parser: Don't create the connection_options array, unless it is actually used.
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Sat, 04 Feb 2017 14:03:25 +0100 |
parents | bf07e3be3f6a |
children | 390c3ef87cc8 |
files | src/lib-http/http-message-parser.c src/lib-http/http-request.c |
diffstat | 2 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-http/http-message-parser.c Tue Feb 14 17:35:54 2017 +0200 +++ b/src/lib-http/http-message-parser.c Sat Feb 04 14:03:25 2017 +0100 @@ -62,7 +62,6 @@ } parser->msg.date = (time_t)-1; parser->msg.header = http_header_create(parser->msg.pool, 32); - p_array_init(&parser->msg.connection_options, parser->msg.pool, 4); } int http_message_parse_version(struct http_message_parser *parser) @@ -165,6 +164,8 @@ num_tokens++; if (strcasecmp(option, "close") == 0) parser->msg.connection_close = TRUE; + if (!array_is_created(&parser->msg.connection_options)) + p_array_init(&parser->msg.connection_options, parser->msg.pool, 4); opt_idx = array_append_space(&parser->msg.connection_options); *opt_idx = p_strdup(parser->msg.pool, option); } @@ -360,13 +361,15 @@ !msg->connection_close) { const char *const *option; - msg->connection_close = TRUE; - array_foreach(&msg->connection_options, option) { - if (strcasecmp(*option, "Keep-Alive") == 0) { - msg->connection_close = FALSE; - break; + msg->connection_close = TRUE; + if (array_is_created(&parser->msg.connection_options)) { + array_foreach(&msg->connection_options, option) { + if (strcasecmp(*option, "Keep-Alive") == 0) { + msg->connection_close = FALSE; + break; + } } - } + } } return 1; }
--- a/src/lib-http/http-request.c Tue Feb 14 17:35:54 2017 +0200 +++ b/src/lib-http/http-request.c Sat Feb 04 14:03:25 2017 +0100 @@ -11,6 +11,8 @@ { const char *const *opt_idx; + if (!array_is_created(&req->connection_options)) + return FALSE; array_foreach(&req->connection_options, opt_idx) { if (strcasecmp(*opt_idx, option) == 0) return TRUE;