summaryrefslogtreecommitdiff
path: root/src/http-header-glue.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-09-16 04:24:29 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2021-09-16 04:40:12 -0400
commit0b56c16a8b7b0bf110e575af1d1de8ced2436025 (patch)
treea6a31fff85603d4267421b31487f29cf49ee3fd0 /src/http-header-glue.c
parent94053349c23ecfd5e8d426e5f656a469ef65c972 (diff)
downloadlighttpd-git-0b56c16a8b7b0bf110e575af1d1de8ced2436025.tar.gz
[core] reduce oversized mem alloc for backends
reduce oversized memory allocations when reading from backends: avoid extra power-2 allocation for 1 byte ('\0') when data available to read is exactly power-2
Diffstat (limited to 'src/http-header-glue.c')
-rw-r--r--src/http-header-glue.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/http-header-glue.c b/src/http-header-glue.c
index 38a3a76d..a70b510c 100644
--- a/src/http-header-glue.c
+++ b/src/http-header-glue.c
@@ -1207,7 +1207,7 @@ handler_t http_response_read(request_st * const r, http_response_opts * const op
if (avail < toread) {
/*(add avail+toread to reduce allocations when ioctl EOPNOTSUPP)*/
- avail = avail ? avail - 1 + toread : toread;
+ avail = toread < MAX_READ_LIMIT && avail ? avail-1+toread : toread;
avail = chunk_buffer_prepare_append(b, avail);
}