summaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/objstr.c b/py/objstr.c
index 0b11533f8..da925234e 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -699,8 +699,13 @@ STATIC mp_obj_t str_finder(size_t n_args, const mp_obj_t *args, int direction, b
end = str_index_to_ptr(self_type, haystack, haystack_len, args[3], true);
}
+ if (end < start) {
+ goto out_error;
+ }
+
const byte *p = find_subbytes(start, end - start, needle, needle_len, direction);
if (p == NULL) {
+ out_error:
// not found
if (is_index) {
mp_raise_ValueError("substring not found");