diff --git a/src/regex.c b/src/regex.c index e3471e2..727c2ce 100644 --- a/src/regex.c +++ b/src/regex.c @@ -108,7 +108,12 @@ int regexp_compare(struct session *ses, pcre2_code *nodepcre, char *str, char *e return FALSE; } - pcre2_match_data *match_data = pcre2_match_data_create(101, NULL); + static pcre2_match_data *match_data = NULL; + + if (match_data == NULL) + { + match_data = pcre2_match_data_create(101, NULL); + } matches = pcre2_match(regex, (PCRE2_SPTR) str, strlen(str), 0, 0, match_data, NULL); @@ -118,7 +123,6 @@ int regexp_compare(struct session *ses, pcre2_code *nodepcre, char *str, char *e { pcre2_code_free(regex); } - pcre2_match_data_free(match_data); return FALSE; } @@ -127,8 +131,6 @@ int regexp_compare(struct session *ses, pcre2_code *nodepcre, char *str, char *e memcpy(gtd->match, ovector, matches * 2 * sizeof(PCRE2_SIZE)); - pcre2_match_data_free(match_data); - // REGEX_FLAG_FIX handles %1 to %99 usage. Backward compatible. switch (flag) diff --git a/src/vt102.c b/src/vt102.c index a57dff2..0085097 100644 --- a/src/vt102.c +++ b/src/vt102.c @@ -586,15 +586,16 @@ int find_secure_color_code(char *str) int strip_vt102_codes(char *str, char *buf) { char *pti, *pto; + int skip; pti = (char *) str; pto = (char *) buf; while (*pti) { - while (skip_vt102_codes(pti)) + while ((skip = skip_vt102_codes(pti))) { - pti += skip_vt102_codes(pti); + pti += skip; } if (*pti)