mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 04:51:12 +02:00
extmod/modre: Use specific error message if regex is too complex.
If the error reporting mode is at least "normal", report a failure due to a complex regex with a different message. Fixes issue #17150. Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
committed by
Damien George
parent
17951cee87
commit
745bec9ce3
@@ -427,6 +427,9 @@ static mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) {
|
|||||||
const char *re_str = mp_obj_str_get_str(args[0]);
|
const char *re_str = mp_obj_str_get_str(args[0]);
|
||||||
int size = re1_5_sizecode(re_str);
|
int size = re1_5_sizecode(re_str);
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
|
#if MICROPY_ERROR_REPORTING >= MICROPY_ERROR_REPORTING_NORMAL
|
||||||
|
mp_raise_ValueError(MP_ERROR_TEXT("regex too complex"));
|
||||||
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
mp_obj_re_t *o = mp_obj_malloc_var(mp_obj_re_t, re.insts, char, size, (mp_obj_type_t *)&re_type);
|
mp_obj_re_t *o = mp_obj_malloc_var(mp_obj_re_t, re.insts, char, size, (mp_obj_type_t *)&re_type);
|
||||||
|
Reference in New Issue
Block a user