diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c index d7b8e6e30..4d0a67084 100644 --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -156,7 +156,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 559b8b9fb..54e5dd559 100644 --- a/src/stream/ngx_stream_script.c +++ b/src/stream/ngx_stream_script.c @@ -157,7 +157,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 {