From 869527f9e56cfe70083995a0f67c05e05f882ad7 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Wed, 1 Mar 2023 08:56:03 +0000 Subject: [PATCH] Add unsupported error code for jit --- src/pcre2.h.generic | 1 + src/pcre2.h.in | 1 + src/pcre2_error.c | 1 + src/pcre2_jit_compile.c | 6 +++--- testdata/testoutput17 | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pcre2.h.generic b/src/pcre2.h.generic index dad774ce6..dc8ad0752 100644 --- a/src/pcre2.h.generic +++ b/src/pcre2.h.generic @@ -404,6 +404,7 @@ released, the numbers must not be changed. */ #define PCRE2_ERROR_CONVERT_SYNTAX (-64) #define PCRE2_ERROR_INTERNAL_DUPMATCH (-65) #define PCRE2_ERROR_DFA_UINVALID_UTF (-66) +#define PCRE2_ERROR_JIT_UNSUPPORTED (-67) /* Request types for pcre2_pattern_info() */ diff --git a/src/pcre2.h.in b/src/pcre2.h.in index 7202c6337..661a79e7c 100644 --- a/src/pcre2.h.in +++ b/src/pcre2.h.in @@ -404,6 +404,7 @@ released, the numbers must not be changed. */ #define PCRE2_ERROR_CONVERT_SYNTAX (-64) #define PCRE2_ERROR_INTERNAL_DUPMATCH (-65) #define PCRE2_ERROR_DFA_UINVALID_UTF (-66) +#define PCRE2_ERROR_JIT_UNSUPPORTED (-67) /* Request types for pcre2_pattern_info() */ diff --git a/src/pcre2_error.c b/src/pcre2_error.c index 09904c03e..465659071 100644 --- a/src/pcre2_error.c +++ b/src/pcre2_error.c @@ -272,6 +272,7 @@ static const unsigned char match_error_texts[] = /* 65 */ "internal error - duplicate substitution match\0" "PCRE2_MATCH_INVALID_UTF is not supported for DFA matching\0" + "pattern does not supported by jit\0" ; diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c index 1f84293be..26b1f4990 100644 --- a/src/pcre2_jit_compile.c +++ b/src/pcre2_jit_compile.c @@ -13844,7 +13844,7 @@ common->ovector_start += sizeof(sljit_sw); if (!check_opcode_types(common, common->start, ccend)) { SLJIT_FREE(common->optimized_cbracket, allocator_data); - return PCRE2_ERROR_NOMEMORY; + return PCRE2_ERROR_JIT_UNSUPPORTED; } /* Checking flags and updating ovector_start. */ @@ -13919,7 +13919,7 @@ if (private_data_size > SLJIT_MAX_LOCAL_SIZE) { SLJIT_FREE(common->private_data_ptrs, allocator_data); SLJIT_FREE(common->optimized_cbracket, allocator_data); - return PCRE2_ERROR_NOMEMORY; + return PCRE2_ERROR_JIT_UNSUPPORTED; } if (common->has_then) @@ -14462,7 +14462,7 @@ interpreter support) even in the absence of JIT. But now, if there is no JIT support, give an error return. */ #ifndef SUPPORT_JIT -return PCRE2_ERROR_JIT_BADOPTION; +return PCRE2_ERROR_JIT_UNSUPPORTED; #else /* SUPPORT_JIT */ /* There is JIT support. Do the necessary. */ diff --git a/testdata/testoutput17 b/testdata/testoutput17 index b5b2cc8a1..31f76f9c7 100644 --- a/testdata/testoutput17 +++ b/testdata/testoutput17 @@ -9,7 +9,7 @@ Capture group count = 0 May match empty string Subject length lower bound = 0 -JIT compilation was not successful (no more memory) +JIT compilation was not successful (pattern does not supported by jit) # The following pattern cannot be compiled by JIT. @@ -17,7 +17,7 @@ JIT compilation was not successful (no more memory) Capture group count = 0 May match empty string Subject length lower bound = 0 -JIT compilation was not successful (no more memory) +JIT compilation was not successful (pattern does not supported by jit) # Check that an infinite recursion loop is caught.