diff options
Diffstat (limited to 'JavaScriptCore/pcre')
| -rw-r--r-- | JavaScriptCore/pcre/pcre_exec.cpp | 7 | ||||
| -rw-r--r-- | JavaScriptCore/pcre/pcre_internal.h | 36 |
2 files changed, 38 insertions, 5 deletions
diff --git a/JavaScriptCore/pcre/pcre_exec.cpp b/JavaScriptCore/pcre/pcre_exec.cpp index 34e2786..80a092a 100644 --- a/JavaScriptCore/pcre/pcre_exec.cpp +++ b/JavaScriptCore/pcre/pcre_exec.cpp @@ -56,7 +56,7 @@ the JavaScript specification. There are also some supporting functions. */ using namespace WTF; -#ifdef __GNUC__ +#if COMPILER(GCC) #define USE_COMPUTED_GOTO_FOR_MATCH_RECURSION //#define USE_COMPUTED_GOTO_FOR_MATCH_OPCODE_LOOP #endif @@ -175,7 +175,7 @@ reqByte match. */ /* The below limit restricts the number of "recursive" match calls in order to avoid spending exponential time on complex regular expressions. */ -static const unsigned matchLimit = 100000; +static const unsigned matchLimit = 1000000; #ifdef DEBUG /************************************************* @@ -447,6 +447,7 @@ static int match(const UChar* subjectPtr, const unsigned char* instructionPtr, i int min; bool minimize = false; /* Initialization not really needed, but some compilers think so. */ unsigned remainingMatchCount = matchLimit; + int othercase; /* Declare here to avoid errors during jumps */ MatchStack stack; @@ -1186,7 +1187,7 @@ RECURSE: stack.currentFrame->args.instructionPtr += stack.currentFrame->locals.length; if (stack.currentFrame->locals.fc <= 0xFFFF) { - int othercase = md.ignoreCase ? jsc_pcre_ucp_othercase(stack.currentFrame->locals.fc) : -1; + othercase = md.ignoreCase ? jsc_pcre_ucp_othercase(stack.currentFrame->locals.fc) : -1; for (int i = 1; i <= min; i++) { if (*stack.currentFrame->args.subjectPtr != stack.currentFrame->locals.fc && *stack.currentFrame->args.subjectPtr != othercase) diff --git a/JavaScriptCore/pcre/pcre_internal.h b/JavaScriptCore/pcre/pcre_internal.h index 2916765..0016bb5 100644 --- a/JavaScriptCore/pcre/pcre_internal.h +++ b/JavaScriptCore/pcre/pcre_internal.h @@ -85,7 +85,7 @@ total length. */ offsets within the compiled regex. The default is 2, which allows for compiled patterns up to 64K long. */ -#define LINK_SIZE 2 +#define LINK_SIZE 3 /* Define DEBUG to get debugging output on stdout. */ @@ -124,28 +124,60 @@ static inline void put2ByteValue(unsigned char* opcodePtr, int value) opcodePtr[1] = value; } +static inline void put3ByteValue(unsigned char* opcodePtr, int value) +{ + ASSERT(value >= 0 && value <= 0xFFFFFF); + opcodePtr[0] = value >> 16; + opcodePtr[1] = value >> 8; + opcodePtr[2] = value; +} + static inline int get2ByteValue(const unsigned char* opcodePtr) { return (opcodePtr[0] << 8) | opcodePtr[1]; } +static inline int get3ByteValue(const unsigned char* opcodePtr) +{ + return (opcodePtr[0] << 16) | (opcodePtr[1] << 8) | opcodePtr[2]; +} + static inline void put2ByteValueAndAdvance(unsigned char*& opcodePtr, int value) { put2ByteValue(opcodePtr, value); opcodePtr += 2; } +static inline void put3ByteValueAndAdvance(unsigned char*& opcodePtr, int value) +{ + put3ByteValue(opcodePtr, value); + opcodePtr += 3; +} + static inline void putLinkValueAllowZero(unsigned char* opcodePtr, int value) { +#if LINK_SIZE == 3 + put3ByteValue(opcodePtr, value); +#elif LINK_SIZE == 2 put2ByteValue(opcodePtr, value); +#else +# error LINK_SIZE not supported. +#endif } static inline int getLinkValueAllowZero(const unsigned char* opcodePtr) { +#if LINK_SIZE == 3 + return get3ByteValue(opcodePtr); +#elif LINK_SIZE == 2 return get2ByteValue(opcodePtr); +#else +# error LINK_SIZE not supported. +#endif } -#define MAX_PATTERN_SIZE (1 << 16) +#define MAX_PATTERN_SIZE 1024 * 1024 // Derived by empirical testing of compile time in PCRE and WREC. +COMPILE_ASSERT(MAX_PATTERN_SIZE < (1 << (8 * LINK_SIZE)), pcre_max_pattern_fits_in_bytecode); static inline void putLinkValue(unsigned char* opcodePtr, int value) { |
