From f09159a0801aeb38f0e2784a9cfa12bf48ed323d Mon Sep 17 00:00:00 2001 From: hai shi Date: Sun, 6 Oct 2019 18:52:02 +0800 Subject: [PATCH] undefined behavior in tailmatch() of bytes_methods.c --- Objects/bytes_methods.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c index 37c5f7dbc8040b..7d131842059228 100644 --- a/Objects/bytes_methods.c +++ b/Objects/bytes_methods.c @@ -743,7 +743,7 @@ tailmatch(const char *str, Py_ssize_t len, PyObject *substr, if (direction < 0) { /* startswith */ - if (start + slen > len) + if (start > len - slen) goto notfound; } else { /* endswith */