diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c index 8f7b548cc..ddae0c1cb 100644 --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -150,7 +150,9 @@ ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv) for (i = 0; i < v->len; i++) { if (v->data[i] == '$') { - if (v->data[i + 1] >= '1' && v->data[i + 1] <= '9') { + if (i + 1 < v->len + && v->data[i + 1] >= '1' && v->data[i + 1] <= '9') + { nc++; } else { diff --git a/src/stream/ngx_stream_script.c b/src/stream/ngx_stream_script.c index c447e152f..175e44194 100644 --- a/src/stream/ngx_stream_script.c +++ b/src/stream/ngx_stream_script.c @@ -151,7 +151,9 @@ ngx_stream_compile_complex_value(ngx_stream_compile_complex_value_t *ccv) for (i = 0; i < v->len; i++) { if (v->data[i] == '$') { - if (v->data[i + 1] >= '1' && v->data[i + 1] <= '9') { + if (i + 1 < v->len + && v->data[i + 1] >= '1' && v->data[i + 1] <= '9') + { nc++; } else {