Skip to content

Commit d65d1f3

Browse files
committed
jit: use correct type when checking for max value
eb42305 (jit: avoid integer wraparound in stack size definition (PCRE2Project#42), 2021-11-19) introduces a check to avoid an integer overflow when allocating stack size for JIT. Unfortunately the maximum value was using PCRE2_SIZE_MAX, eventhough the variable is of type size_t, so correct it. Practically; the issue shouldn't affect the most common configurations where both values are the same, and it will be unlikely that there would be a configuration where PCRE2_SIZE_MAX > SIZE_MAX, hence the mistake is unlikely to have reintroduced the original bug and this change should be therefore mostly equivalent. Signed-off-by: Carlo Marcelo Arenas Belón <[email protected]>
1 parent 80205ee commit d65d1f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pcre2_jit_misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ return NULL;
135135

136136
pcre2_jit_stack *jit_stack;
137137

138-
if (startsize == 0 || maxsize == 0 || maxsize > PCRE2_SIZE_MAX - STACK_GROWTH_RATE)
138+
if (startsize == 0 || maxsize == 0 || maxsize > SIZE_MAX - STACK_GROWTH_RATE)
139139
return NULL;
140140
if (startsize > maxsize)
141141
startsize = maxsize;

0 commit comments

Comments
 (0)