summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 4b0c1e2..8ff63f5 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -351,12 +351,17 @@ mmap_gfind(mmap_object *self,
Py_ssize_t res;
CHECK_VALID_OR_RELEASE(NULL, view);
- if (reverse) {
+ if (end < start) {
+ res = -1;
+ }
+ else if (reverse) {
+ assert(0 <= start && start <= end && end <= self->size);
res = _PyBytes_ReverseFind(
self->data + start, end - start,
view.buf, view.len, start);
}
else {
+ assert(0 <= start && start <= end && end <= self->size);
res = _PyBytes_Find(
self->data + start, end - start,
view.buf, view.len, start);