# HG changeset patch # User Stephan Bosch # Date 1486213405 -3600 # Node ID 219ec946f7c31c91aa783e094fe49f2c1bc6a989 # Parent bf07e3be3f6a61a6200ffea4a97f04b92f2e390d lib-http: message parser: Don't create the connection_options array, unless it is actually used. diff -r bf07e3be3f6a -r 219ec946f7c3 src/lib-http/http-message-parser.c --- 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; } diff -r bf07e3be3f6a -r 219ec946f7c3 src/lib-http/http-request.c --- 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;