diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 45518b4..f3aef28 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -668,8 +668,6 @@ static const uint8_t opcode_possessify[] = { }; -/* FIXME: this is currently incomplete (free JIT?) */ - /************************************************* * Free compiled code * *************************************************/ @@ -677,7 +675,11 @@ static const uint8_t opcode_possessify[] = { PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION pcre2_code_free(pcre2_code *code) { -if (code != NULL) code->memctl.free(code, code->memctl.memory_data); +if (code != NULL) + { + if (code->executable_jit != NULL) PRIV(jit_free(code->executable_jit)); + code->memctl.free(code, code->memctl.memory_data); + } } diff --git a/src/pcre2_internal.h b/src/pcre2_internal.h index 576cc0c..26dd0fd 100644 --- a/src/pcre2_internal.h +++ b/src/pcre2_internal.h @@ -1858,6 +1858,7 @@ is available. */ #define _pcre2_compile_context_init PCRE2_SUFFIX(_pcre2_compile_context_init_) #define _pcre2_find_bracket PCRE2_SUFFIX(_pcre2_find_bracket_) #define _pcre2_is_newline PCRE2_SUFFIX(_pcre2_is_newline_) +#define _pcre2_jit_free PCRE2_SUFFIX(_pcre2_jit_free_) #define _pcre2_jit_get_size PCRE2_SUFFIX(_pcre2_jit_get_size_) #define _pcre2_match_context_init PCRE2_SUFFIX(_pcre2_match_context_init_) #define _pcre2_memctl_malloc PCRE2_SUFFIX(_pcre2_memctl_malloc_) @@ -1877,6 +1878,7 @@ extern void _pcre2_compile_context_init(pcre2_compile_context *, BOOL); extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int); extern BOOL _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, uint32_t *, BOOL); +extern void _pcre2_jit_free(void *); extern size_t _pcre2_jit_get_size(void *); extern void _pcre2_match_context_init(pcre2_match_context *, BOOL); extern void *_pcre2_memctl_malloc(size_t, pcre2_memctl *); diff --git a/src/pcre2_jit_misc.c b/src/pcre2_jit_misc.c index 82a4c04..d70bf4c 100644 --- a/src/pcre2_jit_misc.c +++ b/src/pcre2_jit_misc.c @@ -44,14 +44,29 @@ POSSIBILITY OF SUCH DAMAGE. #endif -/* FIXME: these are dummy functions */ + +/************************************************* +* Free JIT compiled code * +*************************************************/ + +void +PRIV(jit_free)(void *executable_jit) +{ +#ifndef SUPPORT_JIT +(void)executable_jit; +#else /* SUPPORT_JIT */ + +/* Dummy code */ +(void)executable_jit; + +#endif /* SUPPORT_JIT */ +} /************************************************* * Free unused JIT memory * *************************************************/ - PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION pcre2_jit_free_unused_memory(pcre2_general_context *gcontext) {