[njs] HTTP: improved memory allocation error handling.

Dmitry Volyntsev xeioex at nginx.com
Tue May 31 16:32:58 UTC 2022


details:   https://hg.nginx.org/njs/rev/6ccb060f328b
branches:  
changeset: 1867:6ccb060f328b
user:      Sergey Kandaurov <pluknet at nginx.com>
date:      Thu May 26 15:28:06 2022 +0400
description:
HTTP: improved memory allocation error handling.

diffstat:

 nginx/ngx_http_js_module.c |  5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diffs (43 lines):

diff -r 4e4bfbc09cb6 -r 6ccb060f328b nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Tue May 31 08:53:18 2022 -0700
+++ b/nginx/ngx_http_js_module.c	Thu May 26 15:28:06 2022 +0400
@@ -1563,6 +1563,7 @@ ngx_http_js_header_out_special(njs_vm_t 
 
         p = ngx_pnalloc(r->pool, v->length);
         if (p == NULL) {
+            h->hash = 0;
             return NJS_ERROR;
         }
 
@@ -1575,6 +1576,7 @@ ngx_http_js_header_out_special(njs_vm_t 
     if (h != NULL) {
         p = ngx_pnalloc(r->pool, s.length);
         if (p == NULL) {
+            h->hash = 0;
             return NJS_ERROR;
         }
 
@@ -1803,6 +1805,7 @@ ngx_http_js_header_generic(njs_vm_t *vm,
 
         p = ngx_pnalloc(r->pool, name->length);
         if (p == NULL) {
+            h->hash = 0;
             return NJS_ERROR;
         }
 
@@ -1813,6 +1816,7 @@ ngx_http_js_header_generic(njs_vm_t *vm,
 
         p = ngx_pnalloc(r->pool, s.length);
         if (p == NULL) {
+            h->hash = 0;
             return NJS_ERROR;
         }
 
@@ -2858,6 +2862,7 @@ ngx_http_js_ext_variables(njs_vm_t *vm, 
 
     vv->data = ngx_pnalloc(r->pool, s.length);
     if (vv->data == NULL) {
+        vv->valid = 0;
         njs_vm_error(vm, "internal error");
         return NJS_ERROR;
     }



More information about the nginx-devel mailing list