diff options
author | Raymond Hettinger <python@rcn.com> | 2008-07-10 14:03:19 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-07-10 14:03:19 (GMT) |
commit | 3cd1e42dca01308a9f5897ba2efc2aab0bebb661 (patch) | |
tree | 8950458b1bb3e598da4dc22edbbd610ad5e75bfc /Modules/_bisectmodule.c | |
parent | d2cd86ddd5c3d90911a98a1440563118297e45db (diff) | |
download | cpython-3cd1e42dca01308a9f5897ba2efc2aab0bebb661.zip cpython-3cd1e42dca01308a9f5897ba2efc2aab0bebb661.tar.gz cpython-3cd1e42dca01308a9f5897ba2efc2aab0bebb661.tar.bz2 |
Issue 3301: Bisect functions behaved badly when lo was negative.
Diffstat (limited to 'Modules/_bisectmodule.c')
-rw-r--r-- | Modules/_bisectmodule.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c index f8d412a..4870e5d 100644 --- a/Modules/_bisectmodule.c +++ b/Modules/_bisectmodule.c @@ -11,6 +11,10 @@ internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t PyObject *litem; Py_ssize_t mid, res; + if (lo < 0) { + PyErr_SetString(PyExc_ValueError, "lo must be non-negative"); + return -1; + } if (hi == -1) { hi = PySequence_Size(list); if (hi < 0) @@ -108,6 +112,10 @@ internal_bisect_left(PyObject *list, PyObject *item, int lo, int hi) PyObject *litem; int mid, res; + if (lo < 0) { + PyErr_SetString(PyExc_ValueError, "lo must be non-negative"); + return -1; + } if (hi == -1) { hi = PySequence_Size(list); if (hi < 0) |