From 20483678d375e2c14ba8f6b32f4c73e17ed30960 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 a4eb4565c8263c1dbce0881c0f70716c728b1177) --- 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 370154396..723b3a105 100644 --- a/daemon/control_tcp.c +++ b/daemon/control_tcp.c @@ -105,7 +105,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 1fd69f0c9..c3016710e 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; @@ -130,7 +130,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 91eebb6d0..045495333 100644 --- a/include/helpers.h +++ b/include/helpers.h @@ -36,6 +36,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 ***/