summaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-04-02 19:19:43 -0400
committerDan Halbert <halbert@halwitz.org>2018-04-02 19:19:43 -0400
commit435e894fa0ec5e9ce82b7bdef308413c6731e06a (patch)
treeaf8d62363157a6ba969684538e012871a88224c6 /py/objstr.c
parentd005b123267ab4ac2f0471c730b762cc3e94232c (diff)
parent98c7d70fe406d66d80c3c9cc888602f96cf444c4 (diff)
Merge branch 'master' into 3.0_hid
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 64306f54f..7ace1cf73 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -692,8 +692,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");