]> git.kaiwu.me - nginx.git/commitdiff
Removed extra allocation for r->uri.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 10 Dec 2020 17:09:39 +0000 (20:09 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 10 Dec 2020 17:09:39 +0000 (20:09 +0300)
The ngx_http_parse_complex_uri() function cannot make URI longer and does
not null-terminate URI, so there is no need to allocate an extra byte.  This
allocation appears to be a leftover from changes in 461:a88a3e4e158f (0.1.5),
where null-termination of r->uri and many other strings was removed.

src/http/ngx_http_request.c

index 73ab204a26301a8cb81f22a0cd6007ee0aaae9d4..d453b8a497979ddcd33046d2003a13c221020c5e 100644 (file)
@@ -1230,7 +1230,7 @@ ngx_http_process_request_uri(ngx_http_request_t *r)
             r->uri.len++;
         }
 
-        r->uri.data = ngx_pnalloc(r->pool, r->uri.len + 1);
+        r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
         if (r->uri.data == NULL) {
             ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
             return NGX_ERROR;