Skip to content

Commit 982ef4e

Browse files
committed
python#11845: Fix typo in rangeobject.c that caused a crash in compute_slice_indices. Patch by Daniel Urban.
1 parent 34d204b commit 982ef4e

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

Lib/test/test_range.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@ def test_reverse_iteration(self):
498498
]:
499499
self.assertEqual(list(reversed(r)), list(r)[::-1])
500500

501+
def test_issue11845(self):
502+
r = range(*slice(1, 18, 2).indices(20))
503+
values = {None, 0, 1, -1, 2, -2, 5, -5, 19, -19,
504+
20, -20, 21, -21, 30, -30, 99, -99}
505+
for i in values:
506+
for j in values:
507+
for k in values - {0}:
508+
r[i:j:k]
509+
501510

502511
def test_main():
503512
test.support.run_unittest(RangeTest)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.2.1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #11845: Fix typo in rangeobject.c that caused a crash in
14+
compute_slice_indices. Patch by Daniel Urban.
15+
1316
- Issue #11650: PyOS_StdioReadline() retries fgets() if it was interrupted
1417
(EINTR), for example if the program is stopped with CTRL+z on Mac OS X. Patch
1518
written by Charles-Francois Natali.

Objects/rangeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ compute_slice_indices(rangeobject *r, PySliceObject *slice,
472472
if (tmp_stop == NULL) goto Fail;
473473
} else {
474474
tmp_stop = r->length;
475-
Py_INCREF(tmp_start);
475+
Py_INCREF(tmp_stop);
476476
}
477477
}
478478
}

0 commit comments

Comments
 (0)