diff options
author | Yann Ylavic <ylavic@apache.org> | 2022-01-23 20:48:29 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2022-01-23 20:48:29 +0000 |
commit | 225d471b6ea6efe475540348d72b3cb070182bc7 (patch) | |
tree | 24b461a77d570323c8a1f17d7b04744c9f4c27fa | |
parent | 12c24606abf4bc707bb69e9bc898437f45547877 (diff) | |
download | httpd-225d471b6ea6efe475540348d72b3cb070182bc7.tar.gz |
ap_regex: Follow up to r1897240: cleanup PCRE2 match data on exit.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897386 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | server/util_pcre.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/server/util_pcre.c b/server/util_pcre.c index 71f02641d9..1af3e13d0c 100644 --- a/server/util_pcre.c +++ b/server/util_pcre.c @@ -320,16 +320,27 @@ void free_match_data(match_data_pt data, apr_size_t size) #ifdef APR_HAS_THREAD_LOCAL +struct apreg_tls { + match_data_pt data; + apr_size_t size; +}; + +#ifdef HAVE_PCRE2 +static apr_status_t apreg_tls_cleanup(void *arg) +{ + struct apreg_tls *tls = arg; + pcre2_match_data_free(tls->data); /* NULL safe */ + return APR_SUCCESS; +} +#endif + static match_data_pt get_match_data(apr_size_t size, match_vector_pt *ovector, match_vector_pt small_vector, int *to_free) { apr_thread_t *current; - struct { - match_data_pt data; - apr_size_t size; - } *tls = NULL; + struct apreg_tls *tls = NULL; /* Even though APR_HAS_THREAD_LOCAL is compiled in we may still be * called by a native/non-apr thread, let's fall back to alloc/free @@ -346,7 +357,11 @@ static match_data_pt get_match_data(apr_size_t size, apr_pool_t *tp = apr_thread_pool_get(current); if (!tls) { tls = apr_pcalloc(tp, sizeof(*tls)); +#ifdef HAVE_PCRE2 + apr_thread_data_set(tls, "apreg", apreg_tls_cleanup, current); +#else apr_thread_data_set(tls, "apreg", NULL, current); +#endif } tls->size *= 2; |