From cfb9342aa8982684bf63ace81130655efeddc24e Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 17 Oct 2024 09:06:22 -0400 Subject: [PATCH] MT#55283 fix compilation error for pcre2 >= 10.43 The pcre2 API was changed from pcre2_substring_list_free(PCRE2_SPTR *) to pcre2_substring_list_free(PCRE2_UCHAR **) in 10.43. The difference is a `const` qualifier. Work around this. Closes #1869 Change-Id: Ib3dd3003352f6c3155bb47d69ecb7a1b02f4647a (cherry picked from commit 4ebebe08d8bf7f9d35c0f5c65822d5983fc1eff1) (cherry picked from commit b75c598c524f149b8f4052dc6b7e47aa997b72a9) --- daemon/control_tcp.c | 2 +- daemon/control_udp.c | 4 ++-- include/helpers.h | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/daemon/control_tcp.c b/daemon/control_tcp.c index d4295cf43..2ccce732c 100644 --- a/daemon/control_tcp.c +++ b/daemon/control_tcp.c @@ -101,7 +101,7 @@ static int control_stream_parse(struct streambuf_stream *s, char *line) { free(output); } - pcre2_substring_list_free((PCRE2_SPTR *) out); + pcre2_substring_list_free((SUBSTRING_FREE_ARG) out); pcre2_match_data_free(md); log_info_pop(); return 1; diff --git a/daemon/control_udp.c b/daemon/control_udp.c index 4c53cbcdc..76f7f4113 100644 --- a/daemon/control_udp.c +++ b/daemon/control_udp.c @@ -61,7 +61,7 @@ static void control_udp_incoming(struct obj *obj, struct udp_buffer *udp_buf) { socket_sendiov(udp_buf->listener, iov, iovlen, &udp_buf->sin, &udp_buf->local_addr); - pcre2_substring_list_free((PCRE2_SPTR *) out); + pcre2_substring_list_free((SUBSTRING_FREE_ARG) out); pcre2_match_data_free(md); return; @@ -134,7 +134,7 @@ static void control_udp_incoming(struct obj *obj, struct udp_buffer *udp_buf) { cookie_cache_remove(&u->cookie_cache, &cookie); out: - pcre2_substring_list_free((PCRE2_SPTR *) out); + pcre2_substring_list_free((SUBSTRING_FREE_ARG) out); pcre2_match_data_free(md); log_info_pop(); } diff --git a/include/helpers.h b/include/helpers.h index 601647f28..bd4d8e385 100644 --- a/include/helpers.h +++ b/include/helpers.h @@ -32,6 +32,12 @@ int pcre2_multi_match(pcre2_code *, const char *, unsigned int, parse_func, void INLINE void strmove(char **, char **); INLINE void strdupfree(char **, const char *); +#if PCRE2_MAJOR > 10 || (PCRE2_MAJOR == 10 && PCRE2_MINOR >= 43) +#define SUBSTRING_FREE_ARG PCRE2_UCHAR ** +#else +#define SUBSTRING_FREE_ARG PCRE2_SPTR * +#endif + /*** GLIB HELPERS ***/