From 31e7810fe9e2839c6fdd3cabdc974591d09f9bca Mon Sep 17 00:00:00 2001 From: tobil4sk Date: Sat, 7 May 2022 12:23:22 +0100 Subject: [PATCH] Remove MATCH_LIMIT_DEPTH setting altogether Since pcre 10.30, pcre2_match no longer uses recursive function calls, so this setting should no longer be needed. This avoids the memory leak caused by having to configure this setting using a context structure allocated at run time. --- src/std/regexp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/std/regexp.c b/src/std/regexp.c index 900fe9682..7a032dc7a 100644 --- a/src/std/regexp.c +++ b/src/std/regexp.c @@ -25,8 +25,6 @@ typedef struct _ereg ereg; -static pcre2_match_context *match_context; - struct _ereg { void (*finalize)( ereg * ); /* The compiled regex code */ @@ -94,9 +92,6 @@ HL_PRIM ereg *hl_regexp_new_options( vbyte *str, vbyte *opts ) { r->n_groups++; r->match_data = pcre2_match_data_create_from_pattern(r->regex,NULL); - // this is reinitialised for each new regex object... - match_context = pcre2_match_context_create(NULL); - pcre2_set_depth_limit(match_context,3500); // adapted based on Windows 1MB stack size return r; } @@ -120,7 +115,7 @@ HL_PRIM int hl_regexp_matched_num( ereg *e ) { } HL_PRIM bool hl_regexp_match( ereg *e, vbyte *s, int pos, int len ) { - int res = pcre2_match(e->regex,(PCRE2_SPTR)s,pos+len,pos,PCRE2_NO_UTF_CHECK,e->match_data,match_context); + int res = pcre2_match(e->regex,(PCRE2_SPTR)s,pos+len,pos,PCRE2_NO_UTF_CHECK,e->match_data,NULL); e->matched = res >= 0; if( res >= 0 ) return true;