Skip to content

Commit 958a4b6

Browse files
committed
Prevent crash for HTTP/0.9 requests (fix nginxinc#22).
1 parent fc7e69a commit 958a4b6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/http_module.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ ngx_int_t setHeader(ngx_http_request_t* r, StrView name, StrView value)
243243
return NGX_OK;
244244
}
245245

246-
header = (ngx_table_elt_t*)ngx_list_push(&r->headers_in.headers);
246+
auto headers = &r->headers_in.headers;
247+
if (!headers->pool && ngx_list_init(headers, r->pool, 2,
248+
sizeof(ngx_table_elt_t)) != NGX_OK) {
249+
return NGX_ERROR;
250+
}
251+
252+
header = (ngx_table_elt_t*)ngx_list_push(headers);
247253
if (header == NULL) {
248254
return NGX_ERROR;
249255
}

0 commit comments

Comments
 (0)