Skip to content

Commit 25c546a

Browse files
committed
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.
1 parent 431b302 commit 25c546a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/ngx_regex.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,14 +732,14 @@ ngx_regex_create_conf(ngx_cycle_t *cycle)
732732
return NULL;
733733
}
734734

735-
cln->handler = ngx_regex_cleanup;
736-
cln->data = rcf;
737-
738735
rcf->studies = ngx_list_create(cycle->pool, 8, sizeof(ngx_regex_elt_t));
739736
if (rcf->studies == NULL) {
740737
return NULL;
741738
}
742739

740+
cln->handler = ngx_regex_cleanup;
741+
cln->data = rcf;
742+
743743
ngx_regex_studies = rcf->studies;
744744

745745
return rcf;

0 commit comments

Comments
 (0)