summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/modre.c
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2025-06-01 18:47:36 +0200
committerDamien George <damien@micropython.org>2025-06-10 15:14:56 +1000
commit745bec9ce3cc4c95d8e80fcc8f64ffecde1d91bc (patch)
tree1a001f443cfa8f0c40b8dca4aaa35d98f2d93bfd /extmod/modre.c
parent17951cee87d63bcc001fdaf1e669a74e6da4af29 (diff)
downloadmicropython-745bec9ce3cc4c95d8e80fcc8f64ffecde1d91bc.tar.gz
micropython-745bec9ce3cc4c95d8e80fcc8f64ffecde1d91bc.zip
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>
Diffstat (limited to 'extmod/modre.c')
-rw-r--r--extmod/modre.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/extmod/modre.c b/extmod/modre.c
index 1a118009cb..d17ec68d50 100644
--- a/extmod/modre.c
+++ b/extmod/modre.c
@@ -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]);
int size = re1_5_sizecode(re_str);
if (size == -1) {
+ #if MICROPY_ERROR_REPORTING >= MICROPY_ERROR_REPORTING_NORMAL
+ mp_raise_ValueError(MP_ERROR_TEXT("regex too complex"));
+ #endif
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);