summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_unit.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/nxt_unit.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/nxt_unit.c b/src/nxt_unit.c
index 8b1226f5..0cf32916 100644
--- a/src/nxt_unit.c
+++ b/src/nxt_unit.c
@@ -1316,8 +1316,12 @@ nxt_unit_response_init(nxt_unit_request_info_t *req,
nxt_unit_req_debug(req, "duplicate response init");
}
+ /*
+ * Each field name and value 0-terminated by libunit,
+ * this is the reason of '+ 2' below.
+ */
buf_size = sizeof(nxt_unit_response_t)
- + max_fields_count * sizeof(nxt_unit_field_t)
+ + max_fields_count * (sizeof(nxt_unit_field_t) + 2)
+ max_fields_size;
if (nxt_slow_path(req->response_buf != NULL)) {
@@ -1391,8 +1395,12 @@ nxt_unit_response_realloc(nxt_unit_request_info_t *req,
return NXT_UNIT_ERROR;
}
+ /*
+ * Each field name and value 0-terminated by libunit,
+ * this is the reason of '+ 2' below.
+ */
buf_size = sizeof(nxt_unit_response_t)
- + max_fields_count * sizeof(nxt_unit_field_t)
+ + max_fields_count * (sizeof(nxt_unit_field_t) + 2)
+ max_fields_size;
nxt_unit_req_debug(req, "realloc %"PRIu32"", buf_size);