[njs] HTTP: setting exception if memory allocation fails.
Dmitry Volyntsev
xeioex at nginx.com
Mon Feb 25 16:01:15 UTC 2019
details: https://hg.nginx.org/njs/rev/7d0b45c56edf
branches:
changeset: 798:7d0b45c56edf
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Mon Feb 25 19:00:54 2019 +0300
description:
HTTP: setting exception if memory allocation fails.
diffstat:
nginx/ngx_http_js_module.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diffs (55 lines):
diff -r 1718603aae6a -r 7d0b45c56edf nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Sat Feb 23 04:21:44 2019 +0300
+++ b/nginx/ngx_http_js_module.c Mon Feb 25 19:00:54 2019 +0300
@@ -1657,6 +1657,7 @@ ngx_http_js_ext_set_variable(njs_vm_t *v
if (v->set_handler != NULL) {
vv = ngx_pcalloc(r->pool, sizeof(ngx_http_variable_value_t));
if (vv == NULL) {
+ njs_vm_error(vm, "internal error");
return NJS_ERROR;
}
@@ -1682,6 +1683,7 @@ ngx_http_js_ext_set_variable(njs_vm_t *v
vv->data = ngx_pnalloc(r->pool, value->length);
if (vv->data == NULL) {
+ njs_vm_error(vm, "internal error");
return NJS_ERROR;
}
@@ -1864,19 +1866,19 @@ ngx_http_js_ext_subrequest(njs_vm_t *vm,
if (has_body) {
rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
if (rb == NULL) {
- return NJS_ERROR;
+ goto memory_error;
}
rb->bufs = ngx_alloc_chain_link(r->pool);
if (rb->bufs == NULL) {
- return NJS_ERROR;
+ goto memory_error;
}
rb->bufs->next = NULL;
rb->bufs->buf = ngx_calloc_buf(r->pool);
if (rb->bufs->buf == NULL) {
- return NJS_ERROR;
+ goto memory_error;
}
rb->bufs->buf->memory = 1;
@@ -1891,6 +1893,12 @@ ngx_http_js_ext_subrequest(njs_vm_t *vm,
}
return NJS_OK;
+
+memory_error:
+
+ njs_vm_error(ctx->vm, "internal error");
+
+ return NJS_ERROR;
}
More information about the nginx-devel
mailing list