Author: Amaury Forgeot d'Arc <amaur...@gmail.com>
Branch: py3.6
Changeset: r93458:dda99c39353f
Date: 2017-12-17 18:57 +0100
http://bitbucket.org/pypy/pypy/changeset/dda99c39353f/

Log:    CPython Issue #29444: Add array bound check in group(), because the
        underlying buffer is mutable. Difficult to test in non-translated
        code...

diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py
--- a/pypy/module/_sre/interp_sre.py
+++ b/pypy/module/_sre/interp_sre.py
@@ -36,6 +36,9 @@
 def slice_w(space, ctx, start, end, w_default):
     if 0 <= start <= end:
         if isinstance(ctx, rsre_core.BufMatchContext):
+            length = ctx._buffer.getlength()
+            start = min(start, length)
+            end = min(end, length)
             return space.newbytes(ctx._buffer.getslice(start, end, 1,
                                                         end-start))
         if isinstance(ctx, rsre_core.StrMatchContext):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to