Skip to content

Commit 443404e

Browse files
committed
atomic store of lz->next
1 parent 6492f2f commit 443404e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Modules/itertoolsmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,8 +1643,9 @@ islice_next(PyObject *op)
16431643
oldnext = FT_ATOMIC_LOAD_SSIZE_RELAXED(lz->next);
16441644
/* The (size_t) cast below avoids the danger of undefined
16451645
behaviour from signed integer overflow. */
1646-
FT_ATOMIC_STORE_SSIZE_RELAXED(lz->next, oldnext + (size_t)lz->step);
1647-
if (lz->next < oldnext || (stop != -1 && lz->next > stop)) {
1646+
Py_ssize_t new_next = oldnext + (size_t)lz->step
1647+
FT_ATOMIC_STORE_SSIZE_RELAXED(lz->next, new_next);
1648+
if (new_next < oldnext || (stop != -1 && new_next > stop)) {
16481649
FT_ATOMIC_STORE_SSIZE_RELAXED(lz->next, stop);
16491650
}
16501651
return item;

0 commit comments

Comments
 (0)