[pypy-commit] pypy unicode-utf8: check for negative index

mattip pypy.commits at gmail.com
Fri Jan 18 06:32:25 EST 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8
Changeset: r95668:e0d70d85d65c
Date: 2019-01-18 13:30 +0200
http://bitbucket.org/pypy/pypy/changeset/e0d70d85d65c/

Log:	check for negative index

diff --git a/rpython/rlib/rutf8.py b/rpython/rlib/rutf8.py
--- a/rpython/rlib/rutf8.py
+++ b/rpython/rlib/rutf8.py
@@ -570,6 +570,8 @@
     logarithmic in the length of the string, plus some constant that
     is not tiny either.
     """
+    if bytepos < 0:
+        return bytepos
     index_min = 0
     index_max = len(storage) - 1
     while index_min < index_max:


More information about the pypy-commit mailing list