fix rangecheck

This commit is contained in:
Joachim Schöberl 2019-09-07 10:31:12 +02:00
parent be40a4d3f1
commit 5ffab34d13

View File

@ -65,7 +65,7 @@ namespace ngcore
if (!slice.compute(self.Size(), &start, &stop, &step, &slicelength))
throw py::error_already_set();
static constexpr int base = IndexBASE<TIND>();
if (start < base || start+slicelength*step >= self.Size()+base)
if (start < base || start+(slicelength-1)*step >= self.Size()+base)
throw py::index_error();
for (size_t i = 0; i < slicelength; i++, start+=step)
self[start] = val;