summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2023-04-18 06:28:46 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2023-04-18 06:28:46 +0300
commit25c546ac37ba622b93c1a7075bd7eb447bac17b2 (patch)
tree74845e541d12e9ce26120157abd68d4411c3799c
parent431b302d34333f01bdc334bd1970d5d4aceb5605 (diff)
downloadnginx-25c546ac37ba622b93c1a7075bd7eb447bac17b2.tar.gz
Fixed segfault if regex studies list allocation fails.
The rcf->studies list is unconditionally accessed by ngx_regex_cleanup(), and this used to cause NULL pointer dereference if allocation failed. Fix is to set cleanup handler only when allocation succeeds.
-rw-r--r--src/core/ngx_regex.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c
index bebf3b6a8..91381f499 100644
--- a/src/core/ngx_regex.c
+++ b/src/core/ngx_regex.c
@@ -732,14 +732,14 @@ ngx_regex_create_conf(ngx_cycle_t *cycle)
return NULL;
}
- cln->handler = ngx_regex_cleanup;
- cln->data = rcf;
-
rcf->studies = ngx_list_create(cycle->pool, 8, sizeof(ngx_regex_elt_t));
if (rcf->studies == NULL) {
return NULL;
}
+ cln->handler = ngx_regex_cleanup;
+ cln->data = rcf;
+
ngx_regex_studies = rcf->studies;
return rcf;