@@ -598,7 +598,11 @@ ngx_stream_lua_ffi_compile_regex(const unsigned char *pat, size_t pat_len,
598
598
re_comp .captures = 0 ;
599
599
600
600
} else {
601
+ #if (NGX_PCRE2 )
602
+ ovecsize = (re_comp .captures + 1 ) * 2 ;
603
+ #else
601
604
ovecsize = (re_comp .captures + 1 ) * 3 ;
605
+ #endif
602
606
}
603
607
604
608
dd ("allocating cap with size: %d" , (int ) ovecsize );
@@ -691,21 +695,21 @@ ngx_stream_lua_ffi_exec_regex(ngx_stream_lua_regex_t *re, int flags,
691
695
{
692
696
int rc , exec_opts = 0 ;
693
697
size_t * ov ;
694
- ngx_uint_t ovecsize , n , i ;
698
+ ngx_uint_t ovecpair , n , i ;
695
699
ngx_pool_t * old_pool ;
696
700
697
701
if (flags & NGX_LUA_RE_MODE_DFA ) {
698
- ovecsize = 1 ;
702
+ ovecpair = 1 ;
699
703
re -> ncaptures = 0 ;
700
704
701
705
} else {
702
- ovecsize = re -> ncaptures + 1 ;
706
+ ovecpair = re -> ncaptures + 1 ;
703
707
}
704
708
705
709
old_pool = ngx_stream_lua_pcre_malloc_init (NULL );
706
710
707
711
if (ngx_regex_match_data == NULL
708
- || ovecsize > ngx_regex_match_data_size )
712
+ || ovecpair > ngx_regex_match_data_size )
709
713
{
710
714
/*
711
715
* Allocate a match data if not yet allocated or smaller than
@@ -716,8 +720,8 @@ ngx_stream_lua_ffi_exec_regex(ngx_stream_lua_regex_t *re, int flags,
716
720
pcre2_match_data_free (ngx_regex_match_data );
717
721
}
718
722
719
- ngx_regex_match_data_size = ovecsize ;
720
- ngx_regex_match_data = pcre2_match_data_create (ovecsize , NULL );
723
+ ngx_regex_match_data_size = ovecpair ;
724
+ ngx_regex_match_data = pcre2_match_data_create (ovecpair , NULL );
721
725
722
726
if (ngx_regex_match_data == NULL ) {
723
727
rc = PCRE2_ERROR_NOMEMORY ;
@@ -747,7 +751,7 @@ ngx_stream_lua_ffi_exec_regex(ngx_stream_lua_regex_t *re, int flags,
747
751
#if (NGX_DEBUG )
748
752
ngx_log_debug4 (NGX_LOG_DEBUG_STREAM , ngx_cycle -> log , 0 ,
749
753
"pcre2_match failed: flags 0x%05Xd, options 0x%08Xd, rc %d, "
750
- "ovecsize %ui" , flags , exec_opts , rc , ovecsize );
754
+ "ovecpair %ui" , flags , exec_opts , rc , ovecpair );
751
755
#endif
752
756
753
757
goto failed ;
@@ -759,11 +763,11 @@ ngx_stream_lua_ffi_exec_regex(ngx_stream_lua_regex_t *re, int flags,
759
763
#if (NGX_DEBUG )
760
764
ngx_log_debug5 (NGX_LOG_DEBUG_STREAM , ngx_cycle -> log , 0 ,
761
765
"pcre2_match: flags 0x%05Xd, options 0x%08Xd, rc %d, "
762
- "n %ui, ovecsize %ui" , flags , exec_opts , rc , n , ovecsize );
766
+ "n %ui, ovecpair %ui" , flags , exec_opts , rc , n , ovecpair );
763
767
#endif
764
768
765
- if (n > ovecsize ) {
766
- n = ovecsize ;
769
+ if (n > ovecpair ) {
770
+ n = ovecpair ;
767
771
}
768
772
769
773
for (i = 0 ; i < n ; i ++ ) {
0 commit comments