[nginx] Headers filter: improved memory allocation error handling.

Sergey Kandaurov pluknet at nginx.com
Mon May 30 22:33:08 UTC 2022


details:   https://hg.nginx.org/nginx/rev/e64a1f32065b
branches:  
changeset: 8039:e64a1f32065b
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Mon May 30 21:25:57 2022 +0300
description:
Headers filter: improved memory allocation error handling.

diffstat:

 src/http/modules/ngx_http_headers_filter_module.c |  4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diffs (28 lines):

diff -r 711737177b77 -r e64a1f32065b src/http/modules/ngx_http_headers_filter_module.c
--- a/src/http/modules/ngx_http_headers_filter_module.c	Mon May 30 21:25:56 2022 +0300
+++ b/src/http/modules/ngx_http_headers_filter_module.c	Mon May 30 21:25:57 2022 +0300
@@ -377,6 +377,7 @@ ngx_http_set_expires(ngx_http_request_t 
 
         cc = ngx_list_push(&r->headers_out.headers);
         if (cc == NULL) {
+            e->hash = 0;
             return NGX_ERROR;
         }
 
@@ -410,6 +411,8 @@ ngx_http_set_expires(ngx_http_request_t 
 
     e->value.data = ngx_pnalloc(r->pool, len);
     if (e->value.data == NULL) {
+        e->hash = 0;
+        cc->hash = 0;
         return NGX_ERROR;
     }
 
@@ -447,6 +450,7 @@ ngx_http_set_expires(ngx_http_request_t 
     cc->value.data = ngx_pnalloc(r->pool,
                                  sizeof("max-age=") + NGX_TIME_T_LEN + 1);
     if (cc->value.data == NULL) {
+        cc->hash = 0;
         return NGX_ERROR;
     }
 



More information about the nginx-devel mailing list