From: Timo Sirainen Date: Thu, 11 Jul 2013 07:25:32 +0000 (+0300) Subject: lib-http: Minor change to make sure http_response_header.size is always correct. X-Git-Tag: 2.2.5~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bfb3d8c8f2f156b0b2acec445375b8a08462ab1f;p=thirdparty%2Fdovecot%2Fcore.git lib-http: Minor change to make sure http_response_header.size is always correct. The current http-header-parser already guaranteed that it is, but this change just adds extra guarantees that it won't break in future. Besides, this change improves the performance slightly by avoiding strlen(). --- diff --git a/src/lib-http/http-response-parser.c b/src/lib-http/http-response-parser.c index 76fdb70ef5..2eea86a934 100644 --- a/src/lib-http/http-response-parser.c +++ b/src/lib-http/http-response-parser.c @@ -267,10 +267,12 @@ http_response_parse_header(struct http_response_parser *parser, { struct http_response_header *hdr; struct http_parser hparser; + void *value; hdr = array_append_space(&parser->response->headers); hdr->key = p_strdup(parser->response_pool, name); - hdr->value = p_strndup(parser->response_pool, data, size); + hdr->value = value = p_malloc(parser->response_pool, size+1); + memcpy(value, data, size); hdr->size = size; switch (name[0]) {