Mercurial > hg > nginx
comparison src/http/modules/ngx_http_headers_filter_module.c @ 8039:e64a1f32065b
Headers filter: improved memory allocation error handling.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 May 2022 21:25:57 +0300 |
parents | d26db4f82d7d |
children |
comparison
equal
deleted
inserted
replaced
8038:711737177b77 | 8039:e64a1f32065b |
---|---|
375 | 375 |
376 if (cc == NULL) { | 376 if (cc == NULL) { |
377 | 377 |
378 cc = ngx_list_push(&r->headers_out.headers); | 378 cc = ngx_list_push(&r->headers_out.headers); |
379 if (cc == NULL) { | 379 if (cc == NULL) { |
380 e->hash = 0; | |
380 return NGX_ERROR; | 381 return NGX_ERROR; |
381 } | 382 } |
382 | 383 |
383 r->headers_out.cache_control = cc; | 384 r->headers_out.cache_control = cc; |
384 cc->next = NULL; | 385 cc->next = NULL; |
408 return NGX_OK; | 409 return NGX_OK; |
409 } | 410 } |
410 | 411 |
411 e->value.data = ngx_pnalloc(r->pool, len); | 412 e->value.data = ngx_pnalloc(r->pool, len); |
412 if (e->value.data == NULL) { | 413 if (e->value.data == NULL) { |
414 e->hash = 0; | |
415 cc->hash = 0; | |
413 return NGX_ERROR; | 416 return NGX_ERROR; |
414 } | 417 } |
415 | 418 |
416 if (expires_time == 0 && expires != NGX_HTTP_EXPIRES_DAILY) { | 419 if (expires_time == 0 && expires != NGX_HTTP_EXPIRES_DAILY) { |
417 ngx_memcpy(e->value.data, ngx_cached_http_time.data, | 420 ngx_memcpy(e->value.data, ngx_cached_http_time.data, |
445 } | 448 } |
446 | 449 |
447 cc->value.data = ngx_pnalloc(r->pool, | 450 cc->value.data = ngx_pnalloc(r->pool, |
448 sizeof("max-age=") + NGX_TIME_T_LEN + 1); | 451 sizeof("max-age=") + NGX_TIME_T_LEN + 1); |
449 if (cc->value.data == NULL) { | 452 if (cc->value.data == NULL) { |
453 cc->hash = 0; | |
450 return NGX_ERROR; | 454 return NGX_ERROR; |
451 } | 455 } |
452 | 456 |
453 cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T", max_age) | 457 cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T", max_age) |
454 - cc->value.data; | 458 - cc->value.data; |